From 6fc5d06205a10b5c3a4af37d19ed6d4650b6d42e Mon Sep 17 00:00:00 2001 From: Daniel Campoverde Date: Sun, 26 Nov 2017 13:26:27 -0500 Subject: [PATCH] Previous selected tab based on tab events only --- src/background/tabs.js | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/src/background/tabs.js b/src/background/tabs.js index a5a2adc..4de4dd2 100644 --- a/src/background/tabs.js +++ b/src/background/tabs.js @@ -6,7 +6,6 @@ browser.tabs.onActivated.addListener(tabChangeHandler); function tabChangeHandler(activeInfo) { prevSelTab = currSelTab; currSelTab = activeInfo.tabId; - console.log("prev tab: " + prevSelTab + " - curr tab: " + currSelTab); } const closeTab = (id) => { @@ -69,76 +68,43 @@ const getCompletions = (keyword) => { }; const selectPrevTab = (current, count) => { - browser.tabs.query({ currentWindow: true, active: true }).then((tabs) => { - prevSelTab = tabs[0].id; - }); - return browser.tabs.query({ currentWindow: true }).then((tabs) => { if (tabs.length < 2) { return; } let select = (current - count + tabs.length) % tabs.length; let id = tabs[select].id; - currSelTab = id; return browser.tabs.update(id, { active: true }); }); }; const selectNextTab = (current, count) => { - browser.tabs.query({ currentWindow: true, active: true }).then((tabs) => { - prevSelTab = tabs[0].id; - }); - return browser.tabs.query({ currentWindow: true }).then((tabs) => { if (tabs.length < 2) { return; } let select = (current + count) % tabs.length; let id = tabs[select].id; - currSelTab = id; return browser.tabs.update(id, { active: true }); }); }; const selectFirstTab = () => { - browser.tabs.query({ currentWindow: true, active: true }).then((tabs) => { - prevSelTab = tabs[0].id; - }); - return browser.tabs.query({ currentWindow: true }).then((tabs) => { let id = tabs[0].id; - currSelTab = id; return browser.tabs.update(id, { active: true }); }); }; const selectLastTab = () => { - browser.tabs.query({ currentWindow: true, active: true }).then((tabs) => { - prevSelTab = tabs[0].id; - }); - return browser.tabs.query({ currentWindow: true }).then((tabs) => { let id = tabs[tabs.length - 1].id; - currSelTab = id; return browser.tabs.update(id, { active: true }); }); }; -// const selectPrevSelTab = () => { -// let tmpPrevSelTab = null; -// return browser.tabs.query({ currentWindow: true, active: true }).then( -// (tabs) => { -// tmpPrevSelTab = tabs[0].id; -// browser.tabs.update(prevSelTab, { active: true }); -// prevSelTab = tmpPrevSelTab; -// }); -// }; - const selectPrevSelTab = () => { - let tmpPrevSelTab = prevSelTab; - prevSelTab = currSelTab; - currSelTab = tmpPrevSelTab; - return browser.tabs.update(currSelTab, { active: true }); + return browser.tabs.update(prevSelTab, { active: true }); }; const reload = (current, cache) => {