mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
dont call clearclipboard in a loop
This commit is contained in:
@@ -186,13 +186,18 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService {
|
|||||||
|
|
||||||
copyToClipboard(text: string, options?: any): void {
|
copyToClipboard(text: string, options?: any): void {
|
||||||
const type = options ? options.type : null;
|
const type = options ? options.type : null;
|
||||||
|
const clearing = options ? !!options.clearing : false;
|
||||||
const clearMs: number = options && options.clearMs ? options.clearMs : null;
|
const clearMs: number = options && options.clearMs ? options.clearMs : null;
|
||||||
clipboard.writeText(text, type);
|
clipboard.writeText(text, type);
|
||||||
|
if (!clearing) {
|
||||||
this.messagingService.send('copiedToClipboard', {
|
this.messagingService.send('copiedToClipboard', {
|
||||||
clipboardValue: text,
|
clipboardValue: text,
|
||||||
clearMs: clearMs,
|
clearMs: clearMs,
|
||||||
|
type: type,
|
||||||
|
clearing: clearing,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
readFromClipboard(options?: any): Promise<string> {
|
readFromClipboard(options?: any): Promise<string> {
|
||||||
const type = options ? options.type : null;
|
const type = options ? options.type : null;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export class SystemService implements SystemServiceAbstraction {
|
|||||||
this.clearClipboardTimeoutFunction = 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('', { clearing: true });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.clearClipboardTimeout = setTimeout(async () => {
|
this.clearClipboardTimeout = setTimeout(async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user