simplify onboarding model function naming

This commit is contained in:
Ansh Nanda 2023-08-28 18:47:56 -07:00
parent a231fdf64e
commit bcef7400db
4 changed files with 11 additions and 6 deletions

View file

@ -47,7 +47,12 @@ export class OnboardingModel {
} }
} }
nextScreenName(currentScreenName?: OnboardingStep) { /**
* Returns the name of the next screen in the onboarding process based on the current step or screen name provided.
* @param {OnboardingStep} [currentScreenName]
* @returns name of next screen in the onboarding process
*/
next(currentScreenName?: OnboardingStep) {
if (currentScreenName === 'Welcome' || this.step === 'Welcome') { if (currentScreenName === 'Welcome' || this.step === 'Welcome') {
track('Onboarding:Begin') track('Onboarding:Begin')
this.step = 'RecommendedFeeds' this.step = 'RecommendedFeeds'
@ -78,7 +83,7 @@ export class OnboardingModel {
return this.step === 'Home' return this.step === 'Home'
} }
get isRemaining() { get isActive() {
return !this.isComplete return !this.isComplete
} }
} }

View file

@ -125,7 +125,7 @@ export const RecommendedFeeds = observer(({navigation}: Props) => {
const store = useStores() const store = useStores()
const next = () => { const next = () => {
const nextScreenName = store.onboarding.nextScreenName('RecommendedFeeds') const nextScreenName = store.onboarding.next('RecommendedFeeds')
if (nextScreenName) { if (nextScreenName) {
navigation.navigate(nextScreenName) navigation.navigate(nextScreenName)
} }

View file

@ -25,7 +25,7 @@ export const Welcome = observer(({navigation}: Props) => {
}, [store.shell.minimalShellMode, store]) }, [store.shell.minimalShellMode, store])
const next = () => { const next = () => {
const nextScreenName = store.onboarding.nextScreenName('Welcome') const nextScreenName = store.onboarding.next('Welcome')
if (nextScreenName) { if (nextScreenName) {
navigation.navigate(nextScreenName) navigation.navigate(nextScreenName)
} }

View file

@ -41,10 +41,10 @@ export const HomeScreen = withAuthRequired(
>([]) >([])
React.useEffect(() => { React.useEffect(() => {
if (store.onboarding.isRemaining) { if (store.onboarding.isActive) {
navigation.navigate('Welcome') navigation.navigate('Welcome')
} }
}, [store.onboarding.isRemaining, navigation]) }, [store.onboarding.isActive, navigation])
React.useEffect(() => { React.useEffect(() => {
const {pinned} = store.me.savedFeeds const {pinned} = store.me.savedFeeds