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

@ -1 +1 @@
Subproject commit cd46f64993545a1cb772e2f6a2137a675554f3c3
Subproject commit 38fc0432c3b352628b0114ac98b49ca69ee01675

View File

@ -84,7 +84,7 @@ export class OptionsComponent implements OnInit {
this.dontShowCards = await this.storageService.get<boolean>(ConstantsService.dontShowCardsCurrentTab);
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);

View File

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