aboutsummaryrefslogtreecommitdiff
path: root/src/background/actions/tab.js
blob: 5cf1e8c4dcdbd6c52e7e142c356b8d7040807e98 (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
31
import actions from './index';

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

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 };