code review
* change default keybinding for pin/unpin tab from 'p' to 'zp' * use toggleTabPinned to toggle the tab pinned state, instead of updateTabPinned
This commit is contained in:
parent
c2d2f895a5
commit
87b8280d4b
4 changed files with 13 additions and 9 deletions
|
@ -35,7 +35,7 @@ The default mappings are as follows:
|
||||||
- <kbd>g0</kbd>, <kbd>g$</kbd>: select first or last tab
|
- <kbd>g0</kbd>, <kbd>g$</kbd>: select first or last tab
|
||||||
- <kbd>r</kbd>: reload current tab
|
- <kbd>r</kbd>: reload current tab
|
||||||
- <kbd>R</kbd>: reload current tab without cache
|
- <kbd>R</kbd>: reload current tab without cache
|
||||||
- <kbd>p</kbd>: toggle pin/unpin current tab
|
- <kbd>zp</kbd>: toggle pin/unpin current tab
|
||||||
|
|
||||||
### Navigation
|
### Navigation
|
||||||
- <kbd>f</kbd>: start following links in the page
|
- <kbd>f</kbd>: start following links in the page
|
||||||
|
|
|
@ -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) => {
|
const exec = (operation, tab) => {
|
||||||
switch (operation.type) {
|
switch (operation.type) {
|
||||||
case operations.TAB_CLOSE:
|
case operations.TAB_CLOSE:
|
||||||
|
@ -31,7 +34,7 @@ const exec = (operation, tab) => {
|
||||||
case operations.TAB_UNPIN:
|
case operations.TAB_UNPIN:
|
||||||
return tabs.updateTabPinned(tab, false);
|
return tabs.updateTabPinned(tab, false);
|
||||||
case operations.TAB_TOGGLE_PINNED:
|
case operations.TAB_TOGGLE_PINNED:
|
||||||
return tabs.updateTabPinned(tab);
|
return tabs.toggleTabPinned(tab);
|
||||||
case operations.ZOOM_IN:
|
case operations.ZOOM_IN:
|
||||||
return zooms.zoomIn();
|
return zooms.zoomIn();
|
||||||
case operations.ZOOM_OUT:
|
case operations.ZOOM_OUT:
|
||||||
|
@ -64,5 +67,6 @@ const exec = (operation, tab) => {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/* eslint-enable complexity */
|
||||||
|
|
||||||
export { exec };
|
export { exec };
|
||||||
|
|
|
@ -103,16 +103,16 @@ const reload = (current, cache) => {
|
||||||
const updateTabPinned = (current, pinned) => {
|
const updateTabPinned = (current, pinned) => {
|
||||||
return browser.tabs.query({ currentWindow: true, active: true })
|
return browser.tabs.query({ currentWindow: true, active: true })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
let newPinned = pinned;
|
return browser.tabs.update(current.id, { pinned: pinned });
|
||||||
if (newPinned !== true && newPinned !== false) {
|
|
||||||
newPinned = !current.pinned;
|
|
||||||
}
|
|
||||||
return browser.tabs.update(current.id, { pinned: newPinned });
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toggleTabPinned = (current) => {
|
||||||
|
updateTabPinned(current, !current.pinned);
|
||||||
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
closeTab, reopenTab, selectAt, selectByKeyword, getCompletions,
|
closeTab, reopenTab, selectAt, selectByKeyword, getCompletions,
|
||||||
selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, reload,
|
selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, reload,
|
||||||
updateTabPinned
|
updateTabPinned, toggleTabPinned
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,7 +32,7 @@ export default {
|
||||||
"g$": { "type": "tabs.last" },
|
"g$": { "type": "tabs.last" },
|
||||||
"r": { "type": "tabs.reload", "cache": false },
|
"r": { "type": "tabs.reload", "cache": false },
|
||||||
"R": { "type": "tabs.reload", "cache": true },
|
"R": { "type": "tabs.reload", "cache": true },
|
||||||
"p": { "type": "tabs.pin.toggle" },
|
"zp": { "type": "tabs.pin.toggle" },
|
||||||
"zi": { "type": "zoom.in" },
|
"zi": { "type": "zoom.in" },
|
||||||
"zo": { "type": "zoom.out" },
|
"zo": { "type": "zoom.out" },
|
||||||
"zz": { "type": "zoom.neutral" },
|
"zz": { "type": "zoom.neutral" },
|
||||||
|
|
Reference in a new issue