From 38fc0432c3b352628b0114ac98b49ca69ee01675 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 30 May 2019 09:37:02 -0400 Subject: [PATCH] dont call clearclipboard in a loop --- .../services/electronPlatformUtils.service.ts | 13 +++++++++---- src/services/system.service.ts | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/electron/services/electronPlatformUtils.service.ts b/src/electron/services/electronPlatformUtils.service.ts index b2b01750e08..4539b982e04 100644 --- a/src/electron/services/electronPlatformUtils.service.ts +++ b/src/electron/services/electronPlatformUtils.service.ts @@ -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 { diff --git a/src/services/system.service.ts b/src/services/system.service.ts index 1e492c077f5..a53b39800ed 100644 --- a/src/services/system.service.ts +++ b/src/services/system.service.ts @@ -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 () => {