Add TAB_FIRST operation

jh-changes
Daniel Campoverde 7 years ago
parent aeebdcd3ef
commit a2651f617f
  1. 2
      src/background/actions/operation.js
  2. 13
      src/background/tabs.js
  3. 1
      src/shared/operations.js

@ -20,6 +20,8 @@ const exec = (operation, tab) => {
return tabs.selectPrevTab(tab.index, operation.count);
case operations.TAB_NEXT:
return tabs.selectNextTab(tab.index, operation.count);
case operations.TAB_FIRST:
return tabs.selectFirstTab(tab.index, operation.count);
case operations.TAB_RELOAD:
return tabs.reload(tab, operation.cache);
case operations.ZOOM_IN:

@ -79,6 +79,19 @@ const selectNextTab = (current, count) => {
});
};
const selectFirstTab = (current, count) => {
let id = tabs[0].id;
return browser.tabs.update(id, { active: true });
};
// const selectFirstTab = (current, count) => {
// return browser.tabs.query({ currentWindow: true }).then((tabs) => {
// let select = tabs.length;
// let id = tabs[select].id;
// return browser.tabs.update(id, { active: true });
// });
// };
const reload = (current, cache) => {
return browser.tabs.reload(
current.id,

@ -36,6 +36,7 @@ export default {
TAB_REOPEN: 'tabs.reopen',
TAB_PREV: 'tabs.prev',
TAB_NEXT: 'tabs.next',
TAB_FIRST: 'tabs.first',
TAB_RELOAD: 'tabs.reload',
// Zooms