Skip to content

Commit

Permalink
Improve handling of onboarding URL navigation (#983)
Browse files Browse the repository at this point in the history
  • Loading branch information
ost-ptk authored Apr 27, 2024
1 parent 35a49ef commit b18309c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/background/open-onboarding-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export async function enableOnboardingFlow() {
export async function openOnboardingUi() {
const { tabId, windowId } = await loadState();
let tabExist = false;

if (tabId != null && windowId != null) {
try {
const tab = await tabs.get(tabId);
Expand All @@ -38,7 +39,19 @@ export async function openOnboardingUi() {
}
}

if (!tabExist) {
// this needed for case when the user goes to another url from onboarding
// and then click on Casper Wallet from the extension menu
const tab =
tabId != null &&
(await tabs.get(tabId).catch(() => {
// catch error if the tab does not exist
}));
// check if the tab URL is the onboarding URL
const isOnboardingUrl = tab && tab.url?.includes('onboarding.html');

// create a tab if it does not exist or if it's not an onboarding URL
if (!tabExist || !isOnboardingUrl) {
console.log(123);
tabs
.create({ url: 'onboarding.html', active: true })
.then(tab => {
Expand Down

0 comments on commit b18309c

Please sign in to comment.