From 97bb05147e256699cf1b5e85c4ef88e510b9ace1 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 26 Jan 2021 20:12:04 -0500 Subject: Don't trigger a change event for the initial content of the clipboard (#1321) --- ext/bg/js/clipboard-monitor.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/clipboard-monitor.js b/ext/bg/js/clipboard-monitor.js index 87d8d6fc..7379d7ad 100644 --- a/ext/bg/js/clipboard-monitor.js +++ b/ext/bg/js/clipboard-monitor.js @@ -32,6 +32,7 @@ class ClipboardMonitor extends EventDispatcher { // The token below is used as a unique identifier to ensure that a new clipboard monitor // hasn't been started during the await call. The check below the await call // will exit early if the reference has changed. + let canChange = false; const token = {}; const intervalCallback = async () => { this._timerId = null; @@ -50,11 +51,12 @@ class ClipboardMonitor extends EventDispatcher { text !== this._previousText ) { this._previousText = text; - if (this._japaneseUtil.isStringPartiallyJapanese(text)) { + if (canChange && this._japaneseUtil.isStringPartiallyJapanese(text)) { this.trigger('change', {text}); } } + canChange = true; this._timerId = setTimeout(intervalCallback, this._interval); }; @@ -65,6 +67,7 @@ class ClipboardMonitor extends EventDispatcher { stop() { this._timerToken = null; + this._previousText = null; if (this._timerId !== null) { clearTimeout(this._timerId); this._timerId = null; -- cgit v1.2.3