This repository has been archived on 2020-04-04. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Vim-Vixen/src/background/actions/tab.js
2018-07-08 11:44:37 +09:00

34 lines
712 B
JavaScript

import actions from './index';
const openNewTab = async(
url, openerTabId, background = false, adjacent = false
) => {
if (!adjacent) {
await browser.tabs.create({ url, active: !background });
return { type: '' };
}
let tabs = await browser.tabs.query({
active: true, currentWindow: true
});
await browser.tabs.create({
url,
openerTabId,
active: !background,
index: tabs[0].index + 1
});
return { type: '' };
};
const openToTab = async(url, tab) => {
await browser.tabs.update(tab.id, { url: url });
return { type: '' };
};
const selected = (tabId) => {
return {
type: actions.TAB_SELECTED,
tabId,
};
};
export { openNewTab, openToTab, selected };