From bc6fb4e7d742b40bb18965f5aa3e8a1a867b068e Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 15 May 2021 15:31:54 -0400 Subject: Fix incorrect _updateClipboardMonitorEnabled invocation (#1677) --- ext/js/display/search-display-controller.js | 8 ++++++++ ext/js/display/search-persistent-state-controller.js | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ext/js/display/search-display-controller.js b/ext/js/display/search-display-controller.js index 69c59ab3..95f8b6c1 100644 --- a/ext/js/display/search-display-controller.js +++ b/ext/js/display/search-display-controller.js @@ -50,6 +50,8 @@ class SearchDisplayController { async prepare() { await this._display.updateOptions(); + this._searchPersistentStateController.on('modeChange', this._onModeChange.bind(this)); + chrome.runtime.onMessage.addListener(this._onMessage.bind(this)); yomichan.on('optionsUpdated', this._onOptionsUpdated.bind(this)); @@ -65,6 +67,8 @@ class SearchDisplayController { ['updateSearchQuery', {async: false, handler: this._onExternalSearchUpdate.bind(this)}] ]); + this._updateClipboardMonitorEnabled(); + this._display.autoPlayAudioDelay = 0; this._display.queryParserVisible = true; this._display.setHistorySettings({useBrowserHistory: true}); @@ -217,6 +221,10 @@ class SearchDisplayController { this._setClipboardMonitorEnabled(enabled); } + _onModeChange() { + this._updateClipboardMonitorEnabled(); + } + _setWanakanaEnabled(enabled) { if (this._queryInputEventsSetup && this._wanakanaEnabled === enabled) { return; } diff --git a/ext/js/display/search-persistent-state-controller.js b/ext/js/display/search-persistent-state-controller.js index 56beebc7..28546af8 100644 --- a/ext/js/display/search-persistent-state-controller.js +++ b/ext/js/display/search-persistent-state-controller.js @@ -15,8 +15,9 @@ * along with this program. If not, see . */ -class SearchPersistentStateController { +class SearchPersistentStateController extends EventDispatcher { constructor() { + super(); this._mode = null; } @@ -59,6 +60,6 @@ class SearchPersistentStateController { } this._mode = mode; document.documentElement.dataset.searchMode = (mode !== null ? mode : ''); - this._updateClipboardMonitorEnabled(); + this.trigger('modeChange', {mode}); } } -- cgit v1.2.3