chrome.tabs.update does not work on async request interception, so using a delay

This commit is contained in:
Sebastian 2022-03-15 17:46:09 -03:00
parent c0be242292
commit e84cb95887
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1

View File

@ -226,20 +226,18 @@ function makeSyncWalletRedirect(
.join("&");
innerUrl.hash = innerUrl.hash + "?" + hParams;
}
// if (isFirefox()) {
// // Some platforms don't support the sync redirect (yet), so fall back to
// // async redirect after a timeout.
// const doit = async (): Promise<void> => {
// await waitMs(150);
// const tab = await getTab(tabId);
// if (tab.url === oldUrl) {
// chrome.tabs.update(tabId, { url: innerUrl.href });
// }
// };
// doit();
// }
console.log("redirecting to", innerUrl.href);
chrome.tabs.update(tabId, { url: innerUrl.href });
// Some platforms don't support the sync redirect (yet), so fall back to
// async redirect after a timeout.
const doit = async (): Promise<void> => {
await waitMs(150);
const tab = await getTab(tabId);
if (tab.url === oldUrl) {
console.log("redirecting to", innerUrl.href);
chrome.tabs.update(tabId, { url: innerUrl.href });
}
};
doit();
return { redirectUrl: innerUrl.href };
}