diff options
Diffstat (limited to 'src/background/components')
-rw-r--r-- | src/background/components/operation.js | 7 | ||||
-rw-r--r-- | src/background/components/tab.js | 17 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/background/components/operation.js b/src/background/components/operation.js index b9581c9..9a0b4e1 100644 --- a/src/background/components/operation.js +++ b/src/background/components/operation.js @@ -30,6 +30,8 @@ export default class BackgroundComponent { // eslint-disable-next-line complexity exec(operation, tab) { + let tabState = this.store.getState().tab; + switch (operation.type) { case operations.TAB_CLOSE: return tabs.closeTab(tab.id); @@ -46,7 +48,10 @@ export default class BackgroundComponent { case operations.TAB_LAST: return tabs.selectLastTab(); case operations.TAB_PREV_SEL: - return tabs.selectPrevSelTab(); + if (tabState.previousSelected > 0) { + return tabs.selectTab(tabState.previousSelected); + } + break; case operations.TAB_RELOAD: return tabs.reload(tab, operation.cache); case operations.TAB_PIN: diff --git a/src/background/components/tab.js b/src/background/components/tab.js new file mode 100644 index 0000000..b273546 --- /dev/null +++ b/src/background/components/tab.js @@ -0,0 +1,17 @@ +import * as tabActions from '../actions/tab'; + +export default class TabComponent { + constructor(store) { + this.store = store; + + browser.tabs.onActivated.addListener((info) => { + return browser.tabs.query({ currentWindow: true }).then(() => { + return this.onTabActivated(info); + }); + }); + } + + onTabActivated(info) { + return this.store.dispatch(tabActions.selected(info.tabId)); + } +} |