diff options
Diffstat (limited to 'src/state/persisted')
-rw-r--r-- | src/state/persisted/index.ts | 8 | ||||
-rw-r--r-- | src/state/persisted/schema.ts | 23 |
2 files changed, 25 insertions, 6 deletions
diff --git a/src/state/persisted/index.ts b/src/state/persisted/index.ts index f57172d2f..5fe0f9bd0 100644 --- a/src/state/persisted/index.ts +++ b/src/state/persisted/index.ts @@ -1,11 +1,11 @@ import EventEmitter from 'eventemitter3' + +import BroadcastChannel from '#/lib/broadcast' import {logger} from '#/logger' -import {defaults, Schema} from '#/state/persisted/schema' import {migrate} from '#/state/persisted/legacy' +import {defaults, Schema} from '#/state/persisted/schema' import * as store from '#/state/persisted/store' -import BroadcastChannel from '#/lib/broadcast' - -export type {Schema, PersistedAccount} from '#/state/persisted/schema' +export type {PersistedAccount, Schema} from '#/state/persisted/schema' export {defaults} from '#/state/persisted/schema' const broadcast = new BroadcastChannel('BSKY_BROADCAST_CHANNEL') diff --git a/src/state/persisted/schema.ts b/src/state/persisted/schema.ts index f090365a3..77a79b78e 100644 --- a/src/state/persisted/schema.ts +++ b/src/state/persisted/schema.ts @@ -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(), @@ -63,6 +80,7 @@ export const schema = z.object({ pdsAddressHistory: z.array(z.string()).optional(), disableHaptics: z.boolean().optional(), disableAutoplay: z.boolean().optional(), + kawaii: z.boolean().optional(), }) export type Schema = z.infer<typeof schema> @@ -100,4 +118,5 @@ export const defaults: Schema = { pdsAddressHistory: [], disableHaptics: false, disableAutoplay: prefersReducedMotion, + kawaii: false, } |