Clear all state on signout
parent
e3e4c4366c
commit
11f213ad09
|
@ -32,7 +32,6 @@ export async function setupState() {
|
||||||
})
|
})
|
||||||
|
|
||||||
await rootStore.session.setup()
|
await rootStore.session.setup()
|
||||||
await rootStore.me.load()
|
|
||||||
console.log(rootStore.me)
|
console.log(rootStore.me)
|
||||||
|
|
||||||
return rootStore
|
return rootStore
|
||||||
|
|
|
@ -11,6 +11,13 @@ export class MeModel {
|
||||||
makeAutoObservable(this, {rootStore: false}, {autoBind: true})
|
makeAutoObservable(this, {rootStore: false}, {autoBind: true})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
this.did = undefined
|
||||||
|
this.name = undefined
|
||||||
|
this.displayName = undefined
|
||||||
|
this.description = undefined
|
||||||
|
}
|
||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
const sess = this.rootStore.session
|
const sess = this.rootStore.session
|
||||||
if (sess.isAuthed && sess.data) {
|
if (sess.isAuthed && sess.data) {
|
||||||
|
@ -29,10 +36,7 @@ export class MeModel {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.did = undefined
|
this.clear()
|
||||||
this.name = undefined
|
|
||||||
this.displayName = undefined
|
|
||||||
this.description = undefined
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,6 +168,11 @@ export class NavigationModel {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
this.tabs = [new NavigationTabModel()]
|
||||||
|
this.tabIndex = 0
|
||||||
|
}
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
// =
|
// =
|
||||||
|
|
||||||
|
|
|
@ -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
|
const throwawayInst = new RootStoreModel(AdxApi.service('http://localhost')) // this will be replaced by the loader
|
||||||
|
|
|
@ -124,6 +124,9 @@ export class SessionModel {
|
||||||
try {
|
try {
|
||||||
const sess = await this.rootStore.api.todo.adx.getSession({})
|
const sess = await this.rootStore.api.todo.adx.getSession({})
|
||||||
if (sess.success && this.data && this.data.userdid === sess.data.did) {
|
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
|
return // success
|
||||||
}
|
}
|
||||||
} catch (e: any) {}
|
} catch (e: any) {}
|
||||||
|
@ -156,6 +159,9 @@ export class SessionModel {
|
||||||
userdid: res.data.did,
|
userdid: res.data.did,
|
||||||
})
|
})
|
||||||
this.configureApi()
|
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.setOnboardingStage(OnboardingStage.Init)
|
||||||
this.configureApi()
|
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)
|
console.error('(Minor issue) Failed to delete session on the server', e)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.clear()
|
this.rootStore.clearAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
setOnboardingStage(stage: OnboardingStage | null) {
|
setOnboardingStage(stage: OnboardingStage | null) {
|
||||||
|
|
|
@ -14,8 +14,6 @@ Paul's todo list
|
||||||
- Disable badges for now
|
- Disable badges for now
|
||||||
- Disable editing avi or banner
|
- Disable editing avi or banner
|
||||||
- More button
|
- More button
|
||||||
- Search view
|
|
||||||
- *
|
|
||||||
- Notifications view
|
- Notifications view
|
||||||
- *
|
- *
|
||||||
- Linking
|
- Linking
|
||||||
|
@ -30,3 +28,5 @@ Paul's todo list
|
||||||
- Check that sub components arent reloading too much
|
- Check that sub components arent reloading too much
|
||||||
- Titles are getting screwed up (possibly swipe related)
|
- Titles are getting screwed up (possibly swipe related)
|
||||||
- Likes, RTs?
|
- Likes, RTs?
|
||||||
|
- Thread view sizing off
|
||||||
|
- Home feed not showing own posts
|
Loading…
Reference in New Issue