aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/clipboard-monitor.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-01-26 20:12:04 -0500
committerGitHub <noreply@github.com>2021-01-26 20:12:04 -0500
commit97bb05147e256699cf1b5e85c4ef88e510b9ace1 (patch)
tree6e09eb6e7514d77a7df84168e70075e60ed2a990 /ext/bg/js/clipboard-monitor.js
parent77b7bdb4ceb5e1bd3cbe6fdb2a7d05acfd209382 (diff)
Don't trigger a change event for the initial content of the clipboard (#1321)
Diffstat (limited to 'ext/bg/js/clipboard-monitor.js')
-rw-r--r--ext/bg/js/clipboard-monitor.js5
1 files changed, 4 insertions, 1 deletions
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;