diff --git a/src/App.tsx b/src/App.tsx index 2af2146d92..fb4a0a51d9 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -44,6 +44,8 @@ import { useSession, useSessionApi, } from '#/state/session' +import {initSessionStorage} from '#/state/session/storage' +import {SecureSessionStorageGateSync} from '#/state/session/storage/gate-sync' import {readLastActiveAccount} from '#/state/session/util' import {Provider as ShellStateProvider} from '#/state/shell' import {Provider as ComposerProvider} from '#/state/shell/composer' @@ -152,6 +154,7 @@ function InnerApp() { // Resets the entire tree below when it changes: key={currentAccount?.did}> + @@ -218,9 +221,15 @@ function App() { const [isReady, setIsReady] = useState(false) useEffect(() => { - void Promise.all([initPersistedState(), Geo.resolve(), setupDeviceId]).then( - () => setIsReady(true), - ) + void Promise.all([ + /* + * `initSessionStorage` reads the persisted session blob, so it has to + * follow `initPersistedState`. The rest stay parallel. + */ + initPersistedState().then(() => initSessionStorage()), + Geo.resolve(), + setupDeviceId, + ]).then(() => setIsReady(true)) }, []) if (!isReady) { diff --git a/src/screens/Settings/Settings.tsx b/src/screens/Settings/Settings.tsx index 61af150a99..0faf3dd501 100644 --- a/src/screens/Settings/Settings.tsx +++ b/src/screens/Settings/Settings.tsx @@ -24,6 +24,7 @@ import {useDeleteActorDeclaration} from '#/state/queries/messages/actor-declarat import {useProfileQuery, useProfilesQuery} from '#/state/queries/profile' import {usePdsClient} from '#/state/session' import {type SessionAccount, useSession, useSessionApi} from '#/state/session' +import {clearSessionStorage} from '#/state/session/storage' import {useOnboardingDispatch} from '#/state/shell' import {useLoggedOutViewControls} from '#/state/shell/logged-out' import {useCloseAllActiveElements} from '#/state/util' @@ -410,6 +411,7 @@ function DevOptions() { } const clearAllStorage = async () => { + clearSessionStorage() await clearStorage() Toast.show(l`Storage cleared, you need to restart the app now.`) } diff --git a/src/state/session/index.tsx b/src/state/session/index.tsx index e8e3613ddc..619a954644 100644 --- a/src/state/session/index.tsx +++ b/src/state/session/index.tsx @@ -13,6 +13,7 @@ import {type Client} from '@atproto/lex' import {type SessionData} from '@atproto/lex-password-session' import * as persisted from '#/state/persisted' +import {mirrorSessionSnapshot} from '#/state/session/storage' import {useCloseAllActiveElements} from '#/state/util' import {useGlobalDialogsControlContext} from '#/components/dialogs/Context' import {AnalyticsContext, useAnalyticsBase, utils} from '#/analytics' @@ -119,6 +120,7 @@ class SessionStore { data: redactPersistedSession(persistedData), }) void persisted.write('session', persistedData) + mirrorSessionSnapshot(persistedData) } this.listeners.forEach(listener => listener()) }