You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
723 B
26 lines
723 B
import browser from 'webextension-polyfill';
|
|
import log from 'loglevel';
|
|
|
|
export const returnToOnboardingInitiatorTab = async (onboardingInitiator) => {
|
|
let tab;
|
|
try {
|
|
tab = await browser.tabs.update(onboardingInitiator.id, {
|
|
active: true,
|
|
});
|
|
} catch (error) {
|
|
log.debug(
|
|
`An error occurred while updating tabs in returnToOnboardingInitiatorTab: ${error.message}`,
|
|
);
|
|
}
|
|
|
|
if (tab) {
|
|
window.close();
|
|
} else {
|
|
// this case can happen if the tab was closed since being checked with `browser.tabs.get`
|
|
log.warn(
|
|
`Setting current tab to onboarding initiator has failed; falling back to redirect`,
|
|
);
|
|
|
|
window.location.assign(onboardingInitiator.location);
|
|
}
|
|
};
|
|
|