diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-01-25 11:31:09 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-25 11:31:09 -0600 |
commit | 5f189319157dfed67b331145cdfd322515022b93 (patch) | |
tree | 1a87f8c7dd46552ba137ff898eb972024e413fdd /src/state/models/session.ts | |
parent | 079e1dbe180e7a1a5a58cdab90f154157ed07d23 (diff) | |
download | voidsky-5f189319157dfed67b331145cdfd322515022b93.tar.zst |
Push notification & session management cleanup (#92)
* Add some temporary logging to help suss out the session drop issue * Fix to session resumption: copy session tokens during a resumeSession attempt * Factor out notifee display into a lib and add to storybook * Tune the bg notifications fetch to only get what is needed * Fix: run account update inside a mobx action * Remove debugging logs for sessions * Fixes to bg notifications fetch
Diffstat (limited to 'src/state/models/session.ts')
-rw-r--r-- | src/state/models/session.ts | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/state/models/session.ts b/src/state/models/session.ts index 77c1fb595..bc0a9123f 100644 --- a/src/state/models/session.ts +++ b/src/state/models/session.ts @@ -1,4 +1,4 @@ -import {makeAutoObservable} from 'mobx' +import {makeAutoObservable, runInAction} from 'mobx' import { sessionClient as AtpApi, Session, @@ -298,9 +298,19 @@ export class SessionModel { }) try { const sess = await api.com.atproto.session.get() - if (!sess.success || sess.data.did !== account.did) { + if ( + !sess.success || + sess.data.did !== account.did || + !api.sessionManager.session + ) { return false } + + // copy over the access tokens, as they may have refreshed during the .get() above + runInAction(() => { + account.refreshJwt = api.sessionManager.session?.refreshJwt + account.accessJwt = api.sessionManager.session?.accessJwt + }) } catch (_e) { return false } |