diff options
author | Jiabo Hou <jiabo.hou@hotmail.com> | 2017-11-05 17:59:46 -0500 |
---|---|---|
committer | Jiabo Hou <jiabo.hou@hotmail.com> | 2017-11-05 18:09:02 -0500 |
commit | 87b8280d4bdcaddeac1aff95d9354e1954b7c25a (patch) | |
tree | 9851c73fc77d9d5bd8e9c91f754995de2b3d56e5 /src | |
parent | c2d2f895a5e65cc7a42da39e7ab8acf73cb03fc8 (diff) |
code review
* change default keybinding for pin/unpin tab from 'p' to 'zp'
* use toggleTabPinned to toggle the tab pinned state, instead of updateTabPinned
Diffstat (limited to 'src')
-rw-r--r-- | src/background/actions/operation.js | 6 | ||||
-rw-r--r-- | src/background/tabs.js | 12 | ||||
-rw-r--r-- | src/shared/default-settings.js | 2 |
3 files changed, 12 insertions, 8 deletions
diff --git a/src/background/actions/operation.js b/src/background/actions/operation.js index c45eabd..d0caf80 100644 --- a/src/background/actions/operation.js +++ b/src/background/actions/operation.js @@ -10,6 +10,9 @@ const sendConsoleShowCommand = (tab, command) => { }); }; +// This switch statement is only gonna get longer as more +// features are added, so disable complexity check +/* eslint-disable complexity */ const exec = (operation, tab) => { switch (operation.type) { case operations.TAB_CLOSE: @@ -31,7 +34,7 @@ const exec = (operation, tab) => { case operations.TAB_UNPIN: return tabs.updateTabPinned(tab, false); case operations.TAB_TOGGLE_PINNED: - return tabs.updateTabPinned(tab); + return tabs.toggleTabPinned(tab); case operations.ZOOM_IN: return zooms.zoomIn(); case operations.ZOOM_OUT: @@ -64,5 +67,6 @@ const exec = (operation, tab) => { return Promise.resolve(); } }; +/* eslint-enable complexity */ export { exec }; diff --git a/src/background/tabs.js b/src/background/tabs.js index 38b2ed9..23b3b7b 100644 --- a/src/background/tabs.js +++ b/src/background/tabs.js @@ -103,16 +103,16 @@ 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 }); + return browser.tabs.update(current.id, { pinned: pinned }); }); }; +const toggleTabPinned = (current) => { + updateTabPinned(current, !current.pinned); +}; + export { closeTab, reopenTab, selectAt, selectByKeyword, getCompletions, selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, reload, - updateTabPinned + updateTabPinned, toggleTabPinned }; diff --git a/src/shared/default-settings.js b/src/shared/default-settings.js index 0127933..e45bee6 100644 --- a/src/shared/default-settings.js +++ b/src/shared/default-settings.js @@ -32,7 +32,7 @@ export default { "g$": { "type": "tabs.last" }, "r": { "type": "tabs.reload", "cache": false }, "R": { "type": "tabs.reload", "cache": true }, - "p": { "type": "tabs.pin.toggle" }, + "zp": { "type": "tabs.pin.toggle" }, "zi": { "type": "zoom.in" }, "zo": { "type": "zoom.out" }, "zz": { "type": "zoom.neutral" }, |