Skip to content

Commit

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

[CP Stag] Fix User not redirected to IOU report when logging in after deeplink

(cherry picked from commit 2cdd7d5)

(CP triggered by AndrewGable)
  • Loading branch information
thienlnam authored and OSBotify committed Sep 27, 2024
1 parent 259c383 commit 2af42b0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
39 changes: 21 additions & 18 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2693,28 +2693,31 @@ function openReportFromDeepLink(url: string) {
return;
}

// We need skip deeplinking if the user hasn't completed the guided setup flow.
Welcome.isOnboardingFlowCompleted({
onNotCompleted: () => OnboardingFlow.startOnboardingFlow(),
onCompleted: () => {
const state = navigationRef.getRootState();
const currentFocusedRoute = findFocusedRoute(state);
const handleDeeplinkNavigation = () => {
const state = navigationRef.getRootState();
const currentFocusedRoute = findFocusedRoute(state);

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

if (shouldSkipDeepLinkNavigation(route)) {
return;
}
if (shouldSkipDeepLinkNavigation(route)) {
return;
}

if (isAuthenticated) {
return;
}
if (isAuthenticated) {
return;
}

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

// We need skip deeplinking if the user hasn't completed the guided setup flow.
Welcome.isOnboardingFlowCompleted({
onNotCompleted: OnboardingFlow.startOnboardingFlow,
onCompleted: handleDeeplinkNavigation,
onCanceled: handleDeeplinkNavigation,
});
});
},
Expand Down
4 changes: 3 additions & 1 deletion src/libs/actions/Welcome/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let onboarding: OnboardingData;
type HasCompletedOnboardingFlowProps = {
onCompleted?: () => void;
onNotCompleted?: () => void;
onCanceled?: () => void;
};

type HasOpenedForTheFirstTimeFromHybridAppProps = {
Expand Down Expand Up @@ -50,9 +51,10 @@ function onServerDataReady(): Promise<void> {
}

let isOnboardingInProgress = false;
function isOnboardingFlowCompleted({onCompleted, onNotCompleted}: HasCompletedOnboardingFlowProps) {
function isOnboardingFlowCompleted({onCompleted, onNotCompleted, onCanceled}: HasCompletedOnboardingFlowProps) {
isOnboardingFlowStatusKnownPromise.then(() => {
if (Array.isArray(onboarding) || onboarding?.hasCompletedGuidedSetupFlow === undefined) {
onCanceled?.();
return;
}

Expand Down

0 comments on commit 2af42b0

Please sign in to comment.