diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-10 17:27:55 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-10 17:30:09 +0900 |
commit | 2c40d239f0962f1442f357c0697e4c8aa2eafd31 (patch) | |
tree | f39b952035dab3bde2a4b926b85da78811c03ed3 /src/reducers | |
parent | 359fdb528821844f3c2fda718b82ce229a64b29f (diff) |
background command from reducer
Diffstat (limited to 'src/reducers')
-rw-r--r-- | src/reducers/background.js | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/reducers/background.js b/src/reducers/background.js index eccc8ca..d7d7860 100644 --- a/src/reducers/background.js +++ b/src/reducers/background.js @@ -1,8 +1,9 @@ import * as tabs from '../background/tabs'; +import * as zooms from '../background/zooms'; import * as consoleActions from '../actions/console'; import actions from '../actions'; -const doCompletion = (command, keywords, sendto) => { +const doCompletion = (command, keywords, sender) => { if (command === 'buffer') { return tabs.getCompletions(keywords).then((tabs) => { let items = tabs.map((tab) => { @@ -18,20 +19,34 @@ const doCompletion = (command, keywords, sendto) => { items: items }; return browser.tabs.sendMessage( - sendto, + sender, consoleActions.setCompletions([completions])); }); } return Promise.resolve(); }; - - -export default function reducer(state, action = {}, sendto) { - // TODO hide sendto object +export default function reducer(state, action = {}, sender) { + // TODO hide sender object switch (action.type) { case actions.BACKGROUND_REQUEST_COMPLETIONS: - return doCompletion(action.command, action.keywords, sendto); + return doCompletion(action.command, action.keywords, sender.tab.id); + case actions.TABS_CLOSE: + return tabs.closeTab(sender.tab.id); + case actions.TABS_REOPEN: + return tabs.reopenTab(); + case actions.TABS_PREV: + return tabs.selectPrevTab(sender.tab.index, action.count); + case actions.TABS_NEXT: + return tabs.selectNextTab(sender.tab.index, action.count); + case actions.TABS_RELOAD: + return tabs.reload(sender.tab, action.cache); + case actions.ZOOM_IN: + return zooms.zoomIn(); + case actions.ZOOM_OUT: + return zooms.zoomOut(); + case actions.ZOOM_NEUTRAL: + return zooms.neutral(); default: return Promise.resolve(); } |