Session fixes, pt. 1 (#3762)
* Update persisted schema for new source of truth, implement in existing session (cherry picked from commitb1e5f12bae) * Improve toasts, log caught error, during switch account (cherry picked from commitfe0d150706) * Handle thrown errors from initSession during login (cherry picked from commit2c85c04591) --------- Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
@@ -4,7 +4,10 @@ import {deviceLocales, prefersReducedMotion} from '#/platform/detection'
|
||||
|
||||
const externalEmbedOptions = ['show', 'hide'] as const
|
||||
|
||||
// only data needed for rendering account page
|
||||
/**
|
||||
* A account persisted to storage. Stored in the `accounts[]` array. Contains
|
||||
* base account info and access tokens.
|
||||
*/
|
||||
const accountSchema = z.object({
|
||||
service: z.string(),
|
||||
did: z.string(),
|
||||
@@ -19,12 +22,26 @@ const accountSchema = z.object({
|
||||
})
|
||||
export type PersistedAccount = z.infer<typeof accountSchema>
|
||||
|
||||
/**
|
||||
* The current account. Stored in the `currentAccount` field.
|
||||
*
|
||||
* In previous versions, this included tokens and other info. Now, it's used
|
||||
* only to reference the `did` field, and all other fields are marked as
|
||||
* optional. They should be considered deprecated and not used, but are kept
|
||||
* here for backwards compat.
|
||||
*/
|
||||
const currentAccountSchema = accountSchema.extend({
|
||||
service: z.string().optional(),
|
||||
handle: z.string().optional(),
|
||||
})
|
||||
export type PersistedCurrentAccount = z.infer<typeof currentAccountSchema>
|
||||
|
||||
export const schema = z.object({
|
||||
colorMode: z.enum(['system', 'light', 'dark']),
|
||||
darkTheme: z.enum(['dim', 'dark']).optional(),
|
||||
session: z.object({
|
||||
accounts: z.array(accountSchema),
|
||||
currentAccount: accountSchema.optional(),
|
||||
currentAccount: currentAccountSchema.optional(),
|
||||
}),
|
||||
reminders: z.object({
|
||||
lastEmailConfirm: z.string().optional(),
|
||||
|
||||
Reference in New Issue
Block a user