Fix clipboard monitor not persisting (#1315)

* Add optionsUpdated event to Display

* Update this._clipboardMonitorEnabled

* Update settings to ensure no unexpected behaviour
This commit is contained in:
toasted-nutbread 2021-01-25 22:18:31 -05:00 committed by GitHub
parent 981f73b562
commit 34fed22ccb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View File

@ -670,6 +670,7 @@ class OptionsUtil {
// Updated global.useSettingsV2 to be true (opt-out). // Updated global.useSettingsV2 to be true (opt-out).
// Added audio.customSourceType. // Added audio.customSourceType.
// Added general.autoSearchClipboardContent. // 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'); await this._addFieldTemplatesToOptions(options, '/bg/data/anki-field-templates-upgrade-v8.handlebars');
options.global.useSettingsV2 = true; options.global.useSettingsV2 = true;
for (const profile of options.profiles) { for (const profile of options.profiles) {
@ -730,6 +731,7 @@ class OptionsUtil {
}; };
profile.options.audio.customSourceType = 'audio'; profile.options.audio.customSourceType = 'audio';
profile.options.general.autoSearchClipboardContent = true; profile.options.general.autoSearchClipboardContent = true;
profile.options.general.enableClipboardMonitor = false;
} }
return options; return options;
} }

View File

@ -54,6 +54,7 @@ class DisplaySearch extends Display {
await this.updateOptions(); await this.updateOptions();
yomichan.on('optionsUpdated', this._onOptionsUpdated.bind(this)); yomichan.on('optionsUpdated', this._onOptionsUpdated.bind(this));
this.on('optionsUpdated', this._onDisplayOptionsUpdated.bind(this));
this.on('contentUpdating', this._onContentUpdating.bind(this)); this.on('contentUpdating', this._onContentUpdating.bind(this));
this.on('modeChange', this._onModeChange.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.hotkeyHandler.on('keydownNonHotkey', this._onKeyDown.bind(this));
this._onModeChange(); this._onModeChange();
this._onDisplayOptionsUpdated();
this.initializeState(); this.initializeState();
@ -123,6 +125,11 @@ class DisplaySearch extends Display {
} }
} }
_onDisplayOptionsUpdated({options}) {
this._clipboardMonitorEnabled = options.general.enableClipboardMonitor;
this._updateClipboardMonitorEnabled();
}
_onContentUpdating({type, content, source}) { _onContentUpdating({type, content, source}) {
let animate = false; let animate = false;
let valid = false; let valid = false;

View File

@ -313,6 +313,8 @@ class Display extends EventDispatcher {
this._updateNestedFrontend(options); this._updateNestedFrontend(options);
this._updateDefinitionTextScanner(options); this._updateDefinitionTextScanner(options);
this.trigger('optionsUpdated', {options});
} }
clearAutoPlayTimer() { clearAutoPlayTimer() {