-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49586 from software-mansion-labs/fix/onboarding-o…
…ffline Refactor NewDot and HybridApp onboarding flow
- Loading branch information
Showing
14 changed files
with
129 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import {useEffect} from 'react'; | ||
import {NativeModules} from 'react-native'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import {hasCompletedGuidedSetupFlowSelector, hasCompletedHybridAppOnboardingFlowSelector} from '@libs/onboardingSelectors'; | ||
import * as OnboardingFlow from '@userActions/Welcome/OnboardingFlow'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import ROUTES from '@src/ROUTES'; | ||
|
||
/** | ||
* Hook to handle redirection to the onboarding flow based on the user's onboarding status | ||
* | ||
* Warning: This hook should be used only once in the app | ||
*/ | ||
function useOnboardingFlowRouter() { | ||
const [isOnboardingCompleted] = useOnyx(ONYXKEYS.NVP_ONBOARDING, { | ||
selector: hasCompletedGuidedSetupFlowSelector, | ||
}); | ||
const [isHybridAppOnboardingCompleted] = useOnyx(ONYXKEYS.NVP_TRYNEWDOT, { | ||
selector: hasCompletedHybridAppOnboardingFlowSelector, | ||
}); | ||
|
||
useEffect(() => { | ||
if (NativeModules.HybridAppModule) { | ||
// When user is transitioning from OldDot to NewDot, we usually show the explanation modal | ||
if (isHybridAppOnboardingCompleted === false) { | ||
Navigation.navigate(ROUTES.EXPLANATION_MODAL_ROOT); | ||
} | ||
|
||
// But if the hybrid app onboarding is completed, but NewDot onboarding is not completed, we start NewDot onboarding flow | ||
// This is a special case when user created an account from NewDot without finishing the onboarding flow and then logged in from OldDot | ||
if (isHybridAppOnboardingCompleted === true && isOnboardingCompleted === false) { | ||
OnboardingFlow.startOnboardingFlow(); | ||
} | ||
} | ||
|
||
// If the user is not transitioning from OldDot to NewDot, we should start NewDot onboarding flow if it's not completed yet | ||
if (!NativeModules.HybridAppModule && isOnboardingCompleted === false) { | ||
OnboardingFlow.startOnboardingFlow(); | ||
} | ||
}, [isOnboardingCompleted, isHybridAppOnboardingCompleted]); | ||
|
||
return {isOnboardingCompleted, isHybridAppOnboardingCompleted}; | ||
} | ||
|
||
export default useOnboardingFlowRouter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.