diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-10-06 23:03:28 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-10-06 23:40:55 +0900 |
commit | 10ad62e60698c5d53ffcf58ae6abd182f7d3fc9c (patch) | |
tree | d1f4bd11917d9d7a47f5944b520b1e3a00778ee7 /src/components | |
parent | 32168a94e07478325a53779513533b76a6ef2c18 (diff) |
console command actions without store
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/background.js | 12 | ||||
-rw-r--r-- | src/components/console.js | 6 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/components/background.js b/src/components/background.js index 08d5115..195cfd9 100644 --- a/src/components/background.js +++ b/src/components/background.js @@ -1,9 +1,9 @@ import messages from 'content/messages'; -import * as commandActions from 'actions/command'; import * as consoleActions from 'actions/console'; import * as inputActions from 'actions/input'; import * as settingsActions from 'actions/setting'; import * as tabActions from 'actions/tab'; +import * as commands from 'shared/commands'; export default class BackgroundComponent { constructor(store) { @@ -12,7 +12,7 @@ export default class BackgroundComponent { browser.runtime.onMessage.addListener((message, sender) => { try { - this.onMessage(message, sender); + return this.onMessage(message, sender); } catch (e) { this.store.dispatch(consoleActions.showError(e.message), sender); } @@ -47,11 +47,9 @@ export default class BackgroundComponent { return this.store.dispatch( consoleActions.hide(), sender); case messages.CONSOLE_ENTERED: - return this.store.dispatch( - commandActions.exec(message.text, this.settings), sender); - case messages.CONSOLE_CHANGEED: - return this.store.dispatch( - commandActions.complete(message.text, this.settings), sender); + return commands.exec(message.text, this.settings); + case messages.CONSOLE_QUERY_COMPLETIONS: + return commands.complete(message.text, this.settings); case messages.SETTINGS_RELOAD: this.store.dispatch(settingsActions.load()); } diff --git a/src/components/console.js b/src/components/console.js index 25b135c..177cfe5 100644 --- a/src/components/console.js +++ b/src/components/console.js @@ -36,7 +36,7 @@ export default class ConsoleComponent { return browser.runtime.sendMessage({ type: messages.CONSOLE_ENTERED, text: e.target.value - }); + }).then(this.onBlur); case KeyboardEvent.DOM_VK_TAB: if (e.shiftKey) { this.store.dispatch(completionActions.selectPrev()); @@ -63,8 +63,10 @@ export default class ConsoleComponent { this.prevValue = e.target.value; return browser.runtime.sendMessage({ - type: messages.CONSOLE_CHANGEED, + type: messages.CONSOLE_QUERY_COMPLETIONS, text: e.target.value + }).then((completions) => { + this.store.dispatch(completionActions.setItems(completions)); }); } |