From e7dcd7f500f9c139835313a573f861a10aa49d18 Mon Sep 17 00:00:00 2001 From: Cornelius Matějka Date: Wed, 22 Nov 2017 19:22:30 +0100 Subject: Pinned tabs are not closeable by 'd' Added binding 'DD' to force tab close which also closes pinned tabs --- src/background/actions/operation.js | 2 ++ src/background/tabs.js | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src/background') diff --git a/src/background/actions/operation.js b/src/background/actions/operation.js index cfee868..1188ea2 100644 --- a/src/background/actions/operation.js +++ b/src/background/actions/operation.js @@ -17,6 +17,8 @@ const exec = (operation, tab) => { switch (operation.type) { case operations.TAB_CLOSE: return tabs.closeTab(tab.id); + case operations.TAB_CLOSE_FORCE: + return tabs.closeTabForce(tab.id); case operations.TAB_REOPEN: return tabs.reopenTab(); case operations.TAB_PREV: diff --git a/src/background/tabs.js b/src/background/tabs.js index d50d8e5..e02932a 100644 --- a/src/background/tabs.js +++ b/src/background/tabs.js @@ -9,6 +9,14 @@ browser.tabs.onActivated.addListener((activeInfo) => { }); const closeTab = (id) => { + return browser.tabs.get(id).then((tab) => { + if(!tab.pinned) { + return browser.tabs.remove(id); + } + }) +}; + +const closeTabForce = (id) => { return browser.tabs.remove(id); }; @@ -130,7 +138,8 @@ const duplicate = (id) => { }; export { - closeTab, reopenTab, selectAt, selectByKeyword, getCompletions, - selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, selectPrevSelTab, - reload, updateTabPinned, toggleTabPinned, duplicate + closeTab, closeTabForce, reopenTab, selectAt, selectByKeyword, + getCompletions, selectPrevTab, selectNextTab, selectFirstTab, + selectLastTab, selectPrevSelTab, reload, updateTabPinned, + toggleTabPinned, duplicate }; -- cgit v1.2.3