Skip to content

Commit

Permalink
Merge pull request #49516 from software-mansion-labs/fix/onboarding-d…
Browse files Browse the repository at this point in the history
…eeplinking

Fix for Deep linking to onboarding and signing up with new gmail bypa…
  • Loading branch information
rlinoz authored Sep 20, 2024
2 parents 513e6b3 + 7e5d008 commit 8383570
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import {prepareDraftComment} from '@libs/DraftCommentUtils';
import * as EmojiUtils from '@libs/EmojiUtils';
import * as Environment from '@libs/Environment/Environment';
import * as ErrorUtils from '@libs/ErrorUtils';
import hasCompletedGuidedSetupFlowSelector from '@libs/hasCompletedGuidedSetupFlowSelector';
import HttpUtils from '@libs/HttpUtils';
import isPublicScreenRoute from '@libs/isPublicScreenRoute';
import * as Localize from '@libs/Localize';
Expand Down Expand Up @@ -2694,32 +2693,29 @@ function openReportFromDeepLink(url: string) {
return;
}

const state = navigationRef.getRootState();
const currentFocusedRoute = findFocusedRoute(state);
const hasCompletedGuidedSetupFlow = hasCompletedGuidedSetupFlowSelector(onboarding);

// We need skip deeplinking if the user hasn't completed the guided setup flow.
if (!hasCompletedGuidedSetupFlow) {
Welcome.isOnboardingFlowCompleted({
onNotCompleted: () => OnboardingFlow.startOnboardingFlow(),
});
return;
}

if (isOnboardingFlowName(currentFocusedRoute?.name)) {
Welcome.setOnboardingErrorMessage(Localize.translateLocal('onboarding.purpose.errorBackButton'));
return;
}

if (shouldSkipDeepLinkNavigation(route)) {
return;
}

if (isAuthenticated) {
return;
}

Navigation.navigate(route as Route, CONST.NAVIGATION.ACTION_TYPE.PUSH);
Welcome.isOnboardingFlowCompleted({
onNotCompleted: () => OnboardingFlow.startOnboardingFlow(),
onCompleted: () => {
const state = navigationRef.getRootState();
const currentFocusedRoute = findFocusedRoute(state);

if (isOnboardingFlowName(currentFocusedRoute?.name)) {
Welcome.setOnboardingErrorMessage(Localize.translateLocal('onboarding.purpose.errorBackButton'));
return;
}

if (shouldSkipDeepLinkNavigation(route)) {
return;
}

if (isAuthenticated) {
return;
}

Navigation.navigate(route as Route, CONST.NAVIGATION.ACTION_TYPE.PUSH);
},
});
});
},
});
Expand Down

0 comments on commit 8383570

Please sign in to comment.