1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 06:13:38 +00:00

dont call clearclipboard in a loop

This commit is contained in:
Kyle Spearrin
2019-05-30 09:37:09 -04:00
parent 92fb43fc2e
commit a60c60529f
3 changed files with 6 additions and 5 deletions

2
jslib

Submodule jslib updated: cd46f64993...38fc0432c3

View File

@@ -84,7 +84,7 @@ export class OptionsComponent implements OnInit {
this.dontShowCards = await this.storageService.get<boolean>(ConstantsService.dontShowCardsCurrentTab); this.dontShowCards = await this.storageService.get<boolean>(ConstantsService.dontShowCardsCurrentTab);
this.dontShowIdentities = await this.storageService.get<boolean>(ConstantsService.dontShowIdentitiesCurrentTab); this.dontShowIdentities = await this.storageService.get<boolean>(ConstantsService.dontShowIdentitiesCurrentTab);
this.disableAutoTotpCopy = !await this.totpService.isAutoCopyEnabled(); this.disableAutoTotpCopy = !(await this.totpService.isAutoCopyEnabled());
this.disableFavicon = await this.storageService.get<boolean>(ConstantsService.disableFaviconKey); this.disableFavicon = await this.storageService.get<boolean>(ConstantsService.disableFaviconKey);

View File

@@ -186,17 +186,18 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
} else if (options && options.doc) { } else if (options && options.doc) {
doc = options.doc; doc = options.doc;
} }
const clearing = options ? !!options.clearing : false;
const clearMs: number = options && options.clearMs ? options.clearMs : null; const clearMs: number = options && options.clearMs ? options.clearMs : null;
if (this.isFirefox() && (win as any).navigator.clipboard && (win as any).navigator.clipboard.writeText) { if (this.isFirefox() && (win as any).navigator.clipboard && (win as any).navigator.clipboard.writeText) {
(win as any).navigator.clipboard.writeText(text).then(() => { (win as any).navigator.clipboard.writeText(text).then(() => {
if (this.clipboardWriteCallback != null) { if (!clearing && this.clipboardWriteCallback != null) {
this.clipboardWriteCallback(text, clearMs); this.clipboardWriteCallback(text, clearMs);
} }
}); });
} else if ((win as any).clipboardData && (win as any).clipboardData.setData) { } else if ((win as any).clipboardData && (win as any).clipboardData.setData) {
// IE specific code path to prevent textarea being shown while dialog is visible. // IE specific code path to prevent textarea being shown while dialog is visible.
(win as any).clipboardData.setData('Text', text); (win as any).clipboardData.setData('Text', text);
if (this.clipboardWriteCallback != null) { if (!clearing && this.clipboardWriteCallback != null) {
this.clipboardWriteCallback(text, clearMs); this.clipboardWriteCallback(text, clearMs);
} }
} else if (doc.queryCommandSupported && doc.queryCommandSupported('copy')) { } else if (doc.queryCommandSupported && doc.queryCommandSupported('copy')) {
@@ -209,7 +210,7 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
try { try {
// Security exception may be thrown by some browsers. // Security exception may be thrown by some browsers.
if (doc.execCommand('copy') && this.clipboardWriteCallback != null) { if (doc.execCommand('copy') && !clearing && this.clipboardWriteCallback != null) {
this.clipboardWriteCallback(text, clearMs); this.clipboardWriteCallback(text, clearMs);
} }
} catch (e) { } catch (e) {