aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-01-25 22:18:31 -0500
committerGitHub <noreply@github.com>2021-01-25 22:18:31 -0500
commit34fed22ccb34720a16097baebc25fe96278be93c (patch)
tree3ec06b9fabf42b3bf4a1f29c823a4a0cec6d7b5e /ext/bg/js
parent981f73b5623249b4c4cead0261eab0e70f620d90 (diff)
Fix clipboard monitor not persisting (#1315)
* Add optionsUpdated event to Display * Update this._clipboardMonitorEnabled * Update settings to ensure no unexpected behaviour
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/options.js2
-rw-r--r--ext/bg/js/search.js7
2 files changed, 9 insertions, 0 deletions
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 1417c975..14b858aa 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -670,6 +670,7 @@ class OptionsUtil {
// Updated global.useSettingsV2 to be true (opt-out).
// Added audio.customSourceType.
// Added general.autoSearchClipboardContent.
+ // Forced general.enableClipboardMonitor to false due to a bug which caused its value to not be read.
await this._addFieldTemplatesToOptions(options, '/bg/data/anki-field-templates-upgrade-v8.handlebars');
options.global.useSettingsV2 = true;
for (const profile of options.profiles) {
@@ -730,6 +731,7 @@ class OptionsUtil {
};
profile.options.audio.customSourceType = 'audio';
profile.options.general.autoSearchClipboardContent = true;
+ profile.options.general.enableClipboardMonitor = false;
}
return options;
}
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js
index 0fcbcd13..3b7e8299 100644
--- a/ext/bg/js/search.js
+++ b/ext/bg/js/search.js
@@ -54,6 +54,7 @@ class DisplaySearch extends Display {
await this.updateOptions();
yomichan.on('optionsUpdated', this._onOptionsUpdated.bind(this));
+ this.on('optionsUpdated', this._onDisplayOptionsUpdated.bind(this));
this.on('contentUpdating', this._onContentUpdating.bind(this));
this.on('modeChange', this._onModeChange.bind(this));
@@ -76,6 +77,7 @@ class DisplaySearch extends Display {
this.hotkeyHandler.on('keydownNonHotkey', this._onKeyDown.bind(this));
this._onModeChange();
+ this._onDisplayOptionsUpdated();
this.initializeState();
@@ -123,6 +125,11 @@ class DisplaySearch extends Display {
}
}
+ _onDisplayOptionsUpdated({options}) {
+ this._clipboardMonitorEnabled = options.general.enableClipboardMonitor;
+ this._updateClipboardMonitorEnabled();
+ }
+
_onContentUpdating({type, content, source}) {
let animate = false;
let valid = false;