aboutsummaryrefslogtreecommitdiff
path: root/src/background/actions/tab.js
blob: 0d439fd49f9c7c6ccd71fdd1a303fa2e562c8651 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import actions from './index';

const openNewTab = (url, openerTabId, background = false, adjacent = false) => {
  if (adjacent) {
    return browser.tabs.query({
      active: true, currentWindow: true
    }).then((tabs) => {
      return browser.tabs.create({
        url,
        openerTabId,
        active: !background,
        index: tabs[0].index + 1
      });
    });
  }
  return browser.tabs.create({ url, active: !background });
};

const openToTab = (url, tab) => {
  return browser.tabs.update(tab.id, { url: url });
};

const selected = (tabId) => {
  return {
    type: actions.TAB_SELECTED,
    tabId,
  };
};

export { openNewTab, openToTab, selected };