mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-12 12:47:14 +01:00
12a088e638
* update to expect promise from browser api polyfill rather than pass callback
27 lines
723 B
JavaScript
27 lines
723 B
JavaScript
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);
|
|
}
|
|
};
|