Previous selected tab as redux
This commit is contained in:
parent
98bc2326ee
commit
2c366ac3b1
8 changed files with 64 additions and 15 deletions
|
@ -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:
|
||||
|
|
17
src/background/components/tab.js
Normal file
17
src/background/components/tab.js
Normal file
|
@ -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));
|
||||
}
|
||||
}
|
Reference in a new issue