From d4fab1c6976f6b47fff89ef89404d6fcc7583021 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 27 Feb 2019 11:06:55 -0500 Subject: [PATCH] clear clipboard setting --- src/services/constants.service.ts | 2 ++ src/services/system.service.ts | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/services/constants.service.ts b/src/services/constants.service.ts index 755e3335e89..4ec0fc0e081 100644 --- a/src/services/constants.service.ts +++ b/src/services/constants.service.ts @@ -20,6 +20,7 @@ export class ConstantsService { static readonly defaultUriMatch: string = 'defaultUriMatch'; static readonly pinProtectedKey: string = 'pinProtectedKey'; static readonly protectedPin: string = 'protectedPin'; + static readonly clearClipboardKey: string = 'clearClipboardKey'; readonly environmentUrlsKey: string = ConstantsService.environmentUrlsKey; readonly disableGaKey: string = ConstantsService.disableGaKey; @@ -41,4 +42,5 @@ export class ConstantsService { readonly defaultUriMatch: string = ConstantsService.defaultUriMatch; readonly pinProtectedKey: string = ConstantsService.pinProtectedKey; readonly protectedPin: string = ConstantsService.protectedPin; + readonly clearClipboardKey: string = ConstantsService.clearClipboardKey; } diff --git a/src/services/system.service.ts b/src/services/system.service.ts index 0bbbd5b805e..310dfacb4df 100644 --- a/src/services/system.service.ts +++ b/src/services/system.service.ts @@ -48,7 +48,7 @@ export class SystemService implements SystemServiceAbstraction { } } - clearClipboard(clipboardValue: string, timeoutMs = 30000): void { + clearClipboard(clipboardValue: string, timeoutMs: number = null): void { if (this.clearClipboardTimeout != null) { clearTimeout(this.clearClipboardTimeout); this.clearClipboardTimeout = null; @@ -56,11 +56,19 @@ export class SystemService implements SystemServiceAbstraction { if (Utils.isNullOrWhitespace(clipboardValue)) { return; } - this.clearClipboardTimeout = setTimeout(async () => { - const clipboardValueNow = await this.platformUtilsService.readFromClipboard(); - if (clipboardValue === clipboardValueNow) { - this.platformUtilsService.copyToClipboard(''); + this.storageService.get(ConstantsService.clearClipboardKey).then((clearSeconds) => { + if (clearSeconds == null) { + return; } - }, timeoutMs); + if (timeoutMs == null) { + timeoutMs = clearSeconds * 1000; + } + this.clearClipboardTimeout = setTimeout(async () => { + const clipboardValueNow = await this.platformUtilsService.readFromClipboard(); + if (clipboardValue === clipboardValueNow) { + this.platformUtilsService.copyToClipboard(''); + } + }, timeoutMs); + }); } }