Add onboarding (WIP)

This commit is contained in:
Paul Frazee 2022-11-07 15:35:51 -06:00
parent b4097e25d6
commit d228a5f4f5
15 changed files with 613 additions and 34 deletions

View file

@ -15,17 +15,8 @@ interface SessionData {
did: string
}
export enum OnboardingStage {
Init = 'init',
}
interface OnboardingState {
stage: OnboardingStage
}
export class SessionModel {
data: SessionData | null = null
onboardingState: OnboardingState | null = null
constructor(public rootStore: RootStoreModel) {
makeAutoObservable(this, {
@ -42,7 +33,6 @@ export class SessionModel {
serialize(): unknown {
return {
data: this.data,
onboardingState: this.onboardingState,
}
}
@ -87,18 +77,6 @@ export class SessionModel {
this.data = data
}
}
if (
this.data &&
hasProp(v, 'onboardingState') &&
isObj(v.onboardingState)
) {
if (
hasProp(v.onboardingState, 'stage') &&
typeof v.onboardingState === 'string'
) {
this.onboardingState = v.onboardingState
}
}
}
}
@ -212,7 +190,7 @@ export class SessionModel {
handle: res.data.handle,
did: res.data.did,
})
this.setOnboardingStage(OnboardingStage.Init)
this.rootStore.onboard.start()
this.configureApi()
this.rootStore.me.load().catch(e => {
console.error('Failed to fetch local user information', e)
@ -228,12 +206,4 @@ export class SessionModel {
}
this.rootStore.clearAll()
}
setOnboardingStage(stage: OnboardingStage | null) {
if (stage === null) {
this.onboardingState = null
} else {
this.onboardingState = {stage}
}
}
}