fix: store PDS URL for session resumption

This commit is contained in:
Mary
2024-04-19 21:17:26 +07:00
parent 480fa10e0b
commit 0b34cbd0a6
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -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<typeof accountSchema>
+6
View File
@@ -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(),
}
}
},