Use async/await on background

This commit is contained in:
Shin'ya Ueoka 2018-06-17 20:21:39 +09:00
parent 88238005ab
commit 48e4bccf0d
12 changed files with 273 additions and 316 deletions

View file

@ -1,19 +1,20 @@
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
});
});
const openNewTab = async(
url, openerTabId, background = false, adjacent = false
) => {
if (!adjacent) {
return browser.tabs.create({ url, active: !background });
}
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) => {