Skip to content

Commit

Permalink
chore: support openerTabId
Browse files Browse the repository at this point in the history
  • Loading branch information
dessant committed Dec 11, 2019
1 parent 82f3f3c commit 7f67120
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@ import browser from 'webextension-polyfill';

const getText = browser.i18n.getMessage;

function createTab(url, {index, active = true} = {}) {
async function createTab(
url,
{index = null, active = true, openerTabId = null} = {}
) {
const props = {url, active};
if (typeof index !== 'undefined') {
if (index !== null) {
props.index = index;
}
if (
openerTabId !== null &&
openerTabId !== browser.tabs.TAB_ID_NONE &&
!(await isAndroid())
) {
props.openerTabId = openerTabId;
}
return browser.tabs.create(props);
}

Expand All @@ -18,4 +28,9 @@ async function getActiveTab() {
return tab;
}

async function isAndroid() {
const {os} = await browser.runtime.getPlatformInfo();
return os === 'android';
}

export {getText, createTab, getActiveTab};

0 comments on commit 7f67120

Please sign in to comment.