diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-14 22:04:42 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-16 21:08:18 +0900 |
commit | 83cb277ba2af2bc2f87ace1d97fa582a7043bcd5 (patch) | |
tree | 1ff5eb02fc6b7b12d0a1e825ba1fdb889a1e095b /src/content | |
parent | 6127fdc285bc430b48259bd6e90b69623b4e76cc (diff) |
consome as store/reducers
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/index.js | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/content/index.js b/src/content/index.js index 527d107..d81e83e 100644 --- a/src/content/index.js +++ b/src/content/index.js @@ -3,18 +3,11 @@ import * as inputActions from '../actions/input'; import * as consoleFrames from '../console/frames'; import * as scrolls from '../content/scrolls'; import * as histories from '../content/histories'; -import actions from '../actions'; import Follow from '../content/follow'; import operations from '../operations'; -import contentReducer from '../reducers/content'; consoleFrames.initialize(window.document); -browser.runtime.onMessage.addListener((action) => { - contentReducer(undefined, action); - return Promise.resolve(); -}); - window.addEventListener("keypress", (e) => { if (e.target instanceof HTMLInputElement) { return; @@ -49,11 +42,17 @@ const execOperation = (operation) => { } } +const update = (state) => { + if (!state.console.commandShown) { + window.focus(); + consoleFrames.blur(window.document); + } +} + browser.runtime.onMessage.addListener((action) => { switch (action.type) { - case actions.CONSOLE_HIDE: - window.focus(); - return consoleFrames.blur(window.document); + case 'state.changed': + return update(action.state); case 'require.content.operation': execOperation(action.operation); return Promise.resolve(); |