mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-27 12:36:14 +01:00
clearPendingClipboard function
This commit is contained in:
parent
b9267c521d
commit
62e9c75357
@ -2,4 +2,5 @@ export abstract class SystemService {
|
|||||||
startProcessReload: () => void;
|
startProcessReload: () => void;
|
||||||
cancelProcessReload: () => void;
|
cancelProcessReload: () => void;
|
||||||
clearClipboard: (clipboardValue: string, timeoutMs?: number) => void;
|
clearClipboard: (clipboardValue: string, timeoutMs?: number) => void;
|
||||||
|
clearPendingClipboard: () => Promise<any>;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import { Utils } from '../misc/utils';
|
|||||||
export class SystemService implements SystemServiceAbstraction {
|
export class SystemService implements SystemServiceAbstraction {
|
||||||
private reloadInterval: any = null;
|
private reloadInterval: any = null;
|
||||||
private clearClipboardTimeout: any = null;
|
private clearClipboardTimeout: any = null;
|
||||||
|
private clearClipboardTimeoutFunction: () => Promise<any> = null;
|
||||||
|
|
||||||
constructor(private storageService: StorageService, private lockService: LockService,
|
constructor(private storageService: StorageService, private lockService: LockService,
|
||||||
private messagingService: MessagingService, private platformUtilsService: PlatformUtilsService,
|
private messagingService: MessagingService, private platformUtilsService: PlatformUtilsService,
|
||||||
@ -63,12 +64,22 @@ export class SystemService implements SystemServiceAbstraction {
|
|||||||
if (timeoutMs == null) {
|
if (timeoutMs == null) {
|
||||||
timeoutMs = clearSeconds * 1000;
|
timeoutMs = clearSeconds * 1000;
|
||||||
}
|
}
|
||||||
this.clearClipboardTimeout = setTimeout(async () => {
|
this.clearClipboardTimeoutFunction = async () => {
|
||||||
const clipboardValueNow = await this.platformUtilsService.readFromClipboard();
|
const clipboardValueNow = await this.platformUtilsService.readFromClipboard();
|
||||||
if (clipboardValue === clipboardValueNow) {
|
if (clipboardValue === clipboardValueNow) {
|
||||||
this.platformUtilsService.copyToClipboard('');
|
this.platformUtilsService.copyToClipboard('');
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
this.clearClipboardTimeout = setTimeout(async () => {
|
||||||
|
await this.clearPendingClipboard();
|
||||||
}, timeoutMs);
|
}, timeoutMs);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async clearPendingClipboard() {
|
||||||
|
if (this.clearClipboardTimeoutFunction != null) {
|
||||||
|
await this.clearClipboardTimeoutFunction();
|
||||||
|
this.clearClipboardTimeoutFunction = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user