Clear all state on signout

zio/stable
Paul Frazee 2022-09-29 13:55:07 -05:00
parent e3e4c4366c
commit 11f213ad09
6 changed files with 32 additions and 9 deletions

View File

@ -32,7 +32,6 @@ export async function setupState() {
})
await rootStore.session.setup()
await rootStore.me.load()
console.log(rootStore.me)
return rootStore

View File

@ -11,6 +11,13 @@ export class MeModel {
makeAutoObservable(this, {rootStore: false}, {autoBind: true})
}
clear() {
this.did = undefined
this.name = undefined
this.displayName = undefined
this.description = undefined
}
async load() {
const sess = this.rootStore.session
if (sess.isAuthed && sess.data) {
@ -29,10 +36,7 @@ export class MeModel {
}
})
} else {
this.did = undefined
this.name = undefined
this.displayName = undefined
this.description = undefined
this.clear()
}
}
}

View File

@ -168,6 +168,11 @@ export class NavigationModel {
})
}
clear() {
this.tabs = [new NavigationTabModel()]
this.tabIndex = 0
}
// accessors
// =

View File

@ -55,6 +55,12 @@ export class RootStoreModel {
}
}
}
clearAll() {
this.session.clear()
this.nav.clear()
this.me.clear()
}
}
const throwawayInst = new RootStoreModel(AdxApi.service('http://localhost')) // this will be replaced by the loader

View File

@ -124,6 +124,9 @@ export class SessionModel {
try {
const sess = await this.rootStore.api.todo.adx.getSession({})
if (sess.success && this.data && this.data.userdid === sess.data.did) {
this.rootStore.me.load().catch(e => {
console.error('Failed to fetch local user information', e)
})
return // success
}
} catch (e: any) {}
@ -156,6 +159,9 @@ export class SessionModel {
userdid: res.data.did,
})
this.configureApi()
this.rootStore.me.load().catch(e => {
console.error('Failed to fetch local user information', e)
})
}
}
@ -186,6 +192,9 @@ export class SessionModel {
})
this.setOnboardingStage(OnboardingStage.Init)
this.configureApi()
this.rootStore.me.load().catch(e => {
console.error('Failed to fetch local user information', e)
})
}
}
@ -195,7 +204,7 @@ export class SessionModel {
console.error('(Minor issue) Failed to delete session on the server', e)
})
}
this.clear()
this.rootStore.clearAll()
}
setOnboardingStage(stage: OnboardingStage | null) {

View File

@ -14,8 +14,6 @@ Paul's todo list
- Disable badges for now
- Disable editing avi or banner
- More button
- Search view
- *
- Notifications view
- *
- Linking
@ -29,4 +27,6 @@ Paul's todo list
- Bugs
- Check that sub components arent reloading too much
- Titles are getting screwed up (possibly swipe related)
- Likes, RTs?
- Likes, RTs?
- Thread view sizing off
- Home feed not showing own posts