diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-07-11 15:20:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-11 15:20:00 -0400 |
commit | ec42a7e4d61dc30c2839a7ff7be44bec131127a5 (patch) | |
tree | 73d0221a3aebab8bf786012d1a61f14483b59df8 /ext/bg/js/search.js | |
parent | 8389cd8ba27f328123fb73e72b24e69a4a6de2c1 (diff) |
Message handler refactor (#660)
* Refactor searchQueryUpdate action
* Use standard message handler style
* Use name "promiseOrResult" for consistency
* Use standard message handler convention for Yomichan message handlers
* Use common message handler invoker
Diffstat (limited to 'ext/bg/js/search.js')
-rw-r--r-- | ext/bg/js/search.js | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 9bbc66f2..52fc19f8 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -61,7 +61,7 @@ class DisplaySearch extends Display { ['Shift', new Set()] ]); this._runtimeMessageHandlers = new Map([ - ['searchQueryUpdate', this._onExternalSearchUpdate.bind(this)] + ['updateSearchQuery', {async: false, handler: this._onExternalSearchUpdate.bind(this)}] ]); this.setOptionsContext({ @@ -206,12 +206,9 @@ class DisplaySearch extends Display { } _onRuntimeMessage({action, params}, sender, callback) { - const handler = this._runtimeMessageHandlers.get(action); - if (typeof handler !== 'function') { return false; } - - const result = handler(params, sender); - callback(result); - return false; + const messageHandler = this._runtimeMessageHandlers.get(action); + if (typeof messageHandler === 'undefined') { return false; } + return yomichan.invokeMessageHandler(messageHandler, params, callback, sender); } _onCopy() { |