1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-02 06:07:06 +01:00
metamask-extension/ui/pages/first-time-flow/onboarding-initiator-util.js
Dan Miller bc6c60cde1 Revert "Merge pull request #15063 from MetaMask/revert-v10.16.0"
This reverts commit 4d42715220, reversing
changes made to f09ab88891.
2022-06-29 13:03:10 -02:30

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);
}
};