dont call clearclipboard in a loop

This commit is contained in:
Kyle Spearrin 2019-05-30 09:37:02 -04:00
parent cd46f64993
commit 38fc0432c3
2 changed files with 10 additions and 5 deletions

View File

@ -186,12 +186,17 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService {
copyToClipboard(text: string, options?: any): void {
const type = options ? options.type : null;
const clearing = options ? !!options.clearing : false;
const clearMs: number = options && options.clearMs ? options.clearMs : null;
clipboard.writeText(text, type);
this.messagingService.send('copiedToClipboard', {
clipboardValue: text,
clearMs: clearMs,
});
if (!clearing) {
this.messagingService.send('copiedToClipboard', {
clipboardValue: text,
clearMs: clearMs,
type: type,
clearing: clearing,
});
}
}
readFromClipboard(options?: any): Promise<string> {

View File

@ -67,7 +67,7 @@ export class SystemService implements SystemServiceAbstraction {
this.clearClipboardTimeoutFunction = async () => {
const clipboardValueNow = await this.platformUtilsService.readFromClipboard();
if (clipboardValue === clipboardValueNow) {
this.platformUtilsService.copyToClipboard('');
this.platformUtilsService.copyToClipboard('', { clearing: true });
}
};
this.clearClipboardTimeout = setTimeout(async () => {