Previous selected tab as redux

This commit is contained in:
Shin'ya Ueoka 2018-05-06 16:11:40 +09:00
parent 98bc2326ee
commit 2c366ac3b1
8 changed files with 64 additions and 15 deletions

View file

@ -1,13 +1,3 @@
let prevSelTab = 1;
let currSelTab = 1;
browser.tabs.onActivated.addListener((activeInfo) => {
return browser.tabs.query({ currentWindow: true }).then(() => {
prevSelTab = currSelTab;
currSelTab = activeInfo.tabId;
});
});
const closeTab = (id) => {
return browser.tabs.get(id).then((tab) => {
if (!tab.pinned) {
@ -102,8 +92,8 @@ const selectLastTab = () => {
});
};
const selectPrevSelTab = () => {
return browser.tabs.update(prevSelTab, { active: true });
const selectTab = (id) => {
return browser.tabs.update(id, { active: true });
};
const reload = (current, cache) => {
@ -131,6 +121,6 @@ const duplicate = (id) => {
export {
closeTab, closeTabForce, reopenTab, selectAt, selectByKeyword,
selectPrevTab, selectNextTab, selectFirstTab,
selectLastTab, selectPrevSelTab, reload, updateTabPinned,
selectLastTab, selectTab, reload, updateTabPinned,
toggleTabPinned, duplicate
};