diff options
Diffstat (limited to 'src/state/index.ts')
-rw-r--r-- | src/state/index.ts | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/state/index.ts b/src/state/index.ts index 541a9a899..1ff3d3b1d 100644 --- a/src/state/index.ts +++ b/src/state/index.ts @@ -18,7 +18,7 @@ export async function setupState() { libapi.doPolyfill() - const api = AtpApi.service(DEFAULT_SERVICE) + const api = AtpApi.service(DEFAULT_SERVICE) as SessionServiceClient rootStore = new RootStoreModel(api) try { data = (await storage.load(ROOT_STATE_STORAGE_KEY)) || {} @@ -28,6 +28,13 @@ export async function setupState() { } await rootStore.session.setup() + // @ts-ignore .on() is correct -prf + api.sessionManager.on('session', () => { + if (!api.sessionManager.session && rootStore.session.isAuthed) { + // reset session + rootStore.session.clear() + } + }) // track changes & save to storage autorun(() => { |