diff options
Diffstat (limited to 'src/background')
-rw-r--r-- | src/background/actions/operation.js | 6 | ||||
-rw-r--r-- | src/background/tabs.js | 14 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/background/actions/operation.js b/src/background/actions/operation.js index a5094c0..c45eabd 100644 --- a/src/background/actions/operation.js +++ b/src/background/actions/operation.js @@ -26,6 +26,12 @@ const exec = (operation, tab) => { return tabs.selectLastTab(); case operations.TAB_RELOAD: return tabs.reload(tab, operation.cache); + case operations.TAB_PIN: + return tabs.updateTabPinned(tab, true); + case operations.TAB_UNPIN: + return tabs.updateTabPinned(tab, false); + case operations.TAB_TOGGLE_PINNED: + return tabs.updateTabPinned(tab); case operations.ZOOM_IN: return zooms.zoomIn(); case operations.ZOOM_OUT: diff --git a/src/background/tabs.js b/src/background/tabs.js index 020c826..38b2ed9 100644 --- a/src/background/tabs.js +++ b/src/background/tabs.js @@ -100,7 +100,19 @@ const reload = (current, cache) => { ); }; +const updateTabPinned = (current, pinned) => { + return browser.tabs.query({ currentWindow: true, active: true }) + .then(() => { + let newPinned = pinned; + if (newPinned !== true && newPinned !== false) { + newPinned = !current.pinned; + } + return browser.tabs.update(current.id, { pinned: newPinned }); + }); +}; + export { closeTab, reopenTab, selectAt, selectByKeyword, getCompletions, - selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, reload + selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, reload, + updateTabPinned }; |