start onboarding only for new account creations

zio/stable
Ansh Nanda 2023-08-28 18:53:58 -07:00
parent bcef7400db
commit 8f0f3be8fb
3 changed files with 17 additions and 20 deletions

View File

@ -14,7 +14,7 @@ type OnboardingStep =
const OnboardingStepsArray = Object.values(OnboardingScreenSteps)
export class OnboardingModel {
// state
step: OnboardingStep = 'Welcome'
step: OnboardingStep = 'Home'
constructor(public rootStore: RootStoreModel) {
makeAutoObservable(this, {
@ -25,7 +25,6 @@ export class OnboardingModel {
}
serialize(): unknown {
console.log('serializing onboarding', this.step)
return {
step: this.step,
}
@ -38,7 +37,6 @@ export class OnboardingModel {
typeof v.step === 'string' &&
OnboardingStepsArray.includes(v.step as OnboardingStep)
) {
console.log('hydrating onboarding', v.step)
this.step = v.step as OnboardingStep
}
} else {
@ -53,16 +51,12 @@ export class OnboardingModel {
* @returns name of next screen in the onboarding process
*/
next(currentScreenName?: OnboardingStep) {
if (currentScreenName === 'Welcome' || this.step === 'Welcome') {
track('Onboarding:Begin')
currentScreenName = currentScreenName || this.step
if (currentScreenName === 'Welcome') {
this.step = 'RecommendedFeeds'
return this.step
} else if (
this.step === 'RecommendedFeeds' ||
currentScreenName === 'RecommendedFeeds'
) {
track('Onboarding:Complete')
this.step = 'Home'
} else if (this.step === 'RecommendedFeeds') {
this.finish()
return this.step
} else {
// if we get here, we're in an invalid state, let's just go Home
@ -70,6 +64,16 @@ export class OnboardingModel {
}
}
start() {
this.step = 'Welcome'
track('Onboarding:Begin')
}
finish() {
this.step = 'Home'
track('Onboarding:Complete')
}
reset() {
this.step = 'Welcome'
}

View File

@ -109,10 +109,10 @@ export class CreateAccountModel {
this.setError('')
this.setIsProcessing(true)
// open the onboarding modal after the session is created
// open the onboarding screens after the session is created
const sessionReadySub = this.rootStore.onSessionReady(() => {
sessionReadySub.remove()
this.rootStore.shell.openModal({name: 'onboarding'})
this.rootStore.onboarding.start()
})
try {

View File

@ -140,10 +140,6 @@ export interface PreferencesHomeFeed {
name: 'preferences-home-feed'
}
export interface OnboardingModal {
name: 'onboarding'
}
export type Modal =
// Account
| AddAppPasswordModal
@ -176,9 +172,6 @@ export type Modal =
| WaitlistModal
| InviteCodesModal
// Onboarding
| OnboardingModal
// Generic
| ConfirmModal