diff options
Diffstat (limited to 'src/background')
-rw-r--r-- | src/background/index.js | 32 | ||||
-rw-r--r-- | src/background/key-queue.js | 19 |
2 files changed, 14 insertions, 37 deletions
diff --git a/src/background/index.js b/src/background/index.js index a80d1ea..cb7a3ff 100644 --- a/src/background/index.js +++ b/src/background/index.js @@ -1,6 +1,5 @@ import * as actions from '../shared/actions'; import * as tabs from './tabs'; -import * as zooms from './zooms'; import KeyQueue from './key-queue'; import backgroundReducers from '../reducers/background'; @@ -15,36 +14,13 @@ const keyPressHandle = (request, sender) => { return Promise.resolve(); } - if (actions.isBackgroundAction(action.type)) { - return doBackgroundAction(sender, action); - } else if (actions.isContentAction(action.type)) { + if (actions.isContentAction(action.type)) { return browser.tabs.sendMessage(sender.tab.id, action); + } else { + return backgroundReducers(undefined, action, sender); } - return Promise.resolve(); }; -const doBackgroundAction = (sender, action) => { - switch(action.type) { - 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, actions.cache); - case actions.ZOOM_IN: - return zooms.zoomIn(); - case actions.ZOOM_OUT: - return zooms.zoomOut(); - case actions.ZOOM_NEUTRAL: - return zooms.neutral(); - } - return Promise.resolve(); -} - const normalizeUrl = (string) => { try { return new URL(string).href @@ -88,5 +64,5 @@ browser.runtime.onMessage.addListener((request, sender) => { }); browser.runtime.onMessage.addListener((action, sender) => { - return backgroundReducers(undefined, action, sender.tab.id); + return backgroundReducers(undefined, action, sender); }); diff --git a/src/background/key-queue.js b/src/background/key-queue.js index b2f5a34..25f1d24 100644 --- a/src/background/key-queue.js +++ b/src/background/key-queue.js @@ -1,3 +1,4 @@ +import newActions from '../actions'; import * as actions from '../shared/actions'; const DEFAULT_KEYMAP = { @@ -17,15 +18,15 @@ const DEFAULT_KEYMAP = { 'G': { type: actions.SCROLL_BOTTOM }, '0': { type: actions.SCROLL_LEFT }, '$': { type: actions.SCROLL_RIGHT }, - 'd': { type: actions.TABS_CLOSE }, - 'u': { type: actions.TABS_REOPEN }, - 'h': { type: actions.TABS_PREV, count: 1 }, - 'l': { type: actions.TABS_NEXT, count: 1 }, - 'r': { type: actions.TABS_RELOAD, cache: false }, - 'R': { type: actions.TABS_RELOAD, cache: true }, - 'zi': { type: actions.ZOOM_IN }, - 'zo': { type: actions.ZOOM_OUT }, - 'zz': { type: actions.ZOOM_NEUTRAL }, + 'd': { type: newActions.TABS_CLOSE }, + 'u': { type: newActions.TABS_REOPEN }, + 'h': { type: newActions.TABS_PREV, count: 1 }, + 'l': { type: newActions.TABS_NEXT, count: 1 }, + 'r': { type: newActions.TABS_RELOAD, cache: false }, + 'R': { type: newActions.TABS_RELOAD, cache: true }, + 'zi': { type: newActions.ZOOM_IN }, + 'zo': { type: newActions.ZOOM_OUT }, + 'zz': { type: newActions.ZOOM_NEUTRAL }, 'f': { type: actions.FOLLOW_START, newTab: false }, 'F': { type: actions.FOLLOW_START, newTab: true }, 'H': { type: actions.HISTORY_PREV }, |