From 0b34cbd0a68db4b29f305a386b2155f05c4fad1a Mon Sep 17 00:00:00 2001 From: Mary Date: Fri, 19 Apr 2024 21:17:26 +0700 Subject: [PATCH] fix: store PDS URL for session resumption --- src/state/persisted/schema.ts | 1 + src/state/session/index.tsx | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/state/persisted/schema.ts b/src/state/persisted/schema.ts index 67e082a95d..2b9238c59f 100644 --- a/src/state/persisted/schema.ts +++ b/src/state/persisted/schema.ts @@ -14,6 +14,7 @@ const accountSchema = z.object({ refreshJwt: z.string().optional(), // optional because it can expire accessJwt: z.string().optional(), // optional because it can expire deactivated: z.boolean().optional(), + pdsUrl: z.string().optional(), }) export type PersistedAccount = z.infer diff --git a/src/state/session/index.tsx b/src/state/session/index.tsx index b88181ebda..47b9f20abf 100644 --- a/src/state/session/index.tsx +++ b/src/state/session/index.tsx @@ -313,6 +313,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) { refreshJwt: agent.session.refreshJwt, accessJwt: agent.session.accessJwt, deactivated: isSessionDeactivated(agent.session.accessJwt), + pdsUrl: agent.pdsUrl?.toString(), } await configureModeration(agent, account) @@ -405,6 +406,10 @@ export function Provider({children}: React.PropsWithChildren<{}>) { logger.debug(`session: attempting to reuse previous session`) agent.session = prevSession + if (account.pdsUrl) { + agent.api.xrpc.uri = agent.pdsUrl = new URL(account.pdsUrl) + } + __globalAgent = agent upsertAccount(account) @@ -479,6 +484,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) { refreshJwt: agent.session.refreshJwt, accessJwt: agent.session.accessJwt, deactivated: isSessionDeactivated(agent.session.accessJwt), + pdsUrl: agent.pdsUrl?.toString(), } } },