@@ -1311,8 +1311,7 @@ export class Clerk implements ClerkInterface {
1311
1311
newSession ?. currentTask &&
1312
1312
this . #options. taskUrls ?. [ newSession ?. currentTask . key ] ;
1313
1313
1314
- const shouldNavigate = ( redirectUrl || taskUrl || setActiveNavigate ) && ! beforeEmit ;
1315
- if ( shouldNavigate ) {
1314
+ if ( ! beforeEmit && ( redirectUrl || taskUrl || setActiveNavigate ) ) {
1316
1315
await tracker . track ( async ( ) => {
1317
1316
if ( ! this . client ) {
1318
1317
// Typescript is not happy because since thinks this.client might have changed to undefined because the function is asynchronous.
@@ -1328,28 +1327,18 @@ export class Clerk implements ClerkInterface {
1328
1327
? buildURL ( { base : taskUrl , hashSearchParams : { redirectUrl } } , { stringify : true } )
1329
1328
: taskUrl ;
1330
1329
await this . navigate ( taskUrlWithRedirect ) ;
1331
- return ;
1332
- }
1333
-
1334
- if ( setActiveNavigate && newSession ) {
1330
+ } else if ( setActiveNavigate && newSession ) {
1335
1331
await setActiveNavigate ( { session : newSession } ) ;
1336
- return ;
1337
- }
1338
-
1339
- if ( ! redirectUrl ) {
1340
- return ;
1341
- }
1342
-
1343
- if ( ! this . client . isEligibleForTouch ( ) ) {
1332
+ } else if ( redirectUrl ) {
1333
+ if ( this . client . isEligibleForTouch ( ) ) {
1334
+ const absoluteRedirectUrl = new URL ( redirectUrl , window . location . href ) ;
1335
+ const redirectUrlWithAuth = this . buildUrlWithAuth (
1336
+ this . client . buildTouchUrl ( { redirectUrl : absoluteRedirectUrl } ) ,
1337
+ ) ;
1338
+ await this . navigate ( redirectUrlWithAuth ) ;
1339
+ }
1344
1340
await this . navigate ( redirectUrl ) ;
1345
- return ;
1346
1341
}
1347
-
1348
- const absoluteRedirectUrl = new URL ( redirectUrl , window . location . href ) ;
1349
- const redirectUrlWithAuth = this . buildUrlWithAuth (
1350
- this . client . buildTouchUrl ( { redirectUrl : absoluteRedirectUrl } ) ,
1351
- ) ;
1352
- await this . navigate ( redirectUrlWithAuth ) ;
1353
1342
} ) ;
1354
1343
}
1355
1344
0 commit comments