diff --git a/src/state/queries/preferences/index.ts b/src/state/queries/preferences/index.ts index b92120dcd6..81beb8e83a 100644 --- a/src/state/queries/preferences/index.ts +++ b/src/state/queries/preferences/index.ts @@ -39,8 +39,7 @@ import { } from '#/state/queries/preferences/types' import {createQueryKey} from '#/state/queries/util' import {useAppviewClient, usePdsClient} from '#/state/session' -import {saveLabelers} from '#/state/session/agent-config' -import {applyLabelersToClient} from '#/state/session/moderation' +import {applyLabelersToClient, saveLabelers} from '#/state/session/moderation' import {useAgeAssurance} from '#/ageAssurance' import {makeAgeRestrictedModerationPrefs} from '#/ageAssurance/util' import {useAnalytics} from '#/analytics' @@ -76,7 +75,7 @@ export function usePreferencesQuery() { const labelerDids = res.moderationPrefs.labelers.map(l => l.did) // save to local storage to ensure there are labels on initial requests - void saveLabelers(client.did, labelerDids) + saveLabelers(client.did, labelerDids) /* * Sync the subscribed labelers to the live appview client, mirroring the diff --git a/src/state/session/agent-config.ts b/src/state/session/agent-config.ts deleted file mode 100644 index 3ee2718a39..0000000000 --- a/src/state/session/agent-config.ts +++ /dev/null @@ -1,12 +0,0 @@ -import AsyncStorage from '@react-native-async-storage/async-storage' - -const PREFIX = 'agent-labelers' - -export async function saveLabelers(did: string, value: string[]) { - await AsyncStorage.setItem(`${PREFIX}:${did}`, JSON.stringify(value)) -} - -export async function readLabelers(did: string): Promise { - const rawData = await AsyncStorage.getItem(`${PREFIX}:${did}`) - return rawData ? JSON.parse(rawData) : undefined -} diff --git a/src/storage/schema.ts b/src/storage/schema.ts index 2f4424792d..53b4ffb022 100644 --- a/src/storage/schema.ts +++ b/src/storage/schema.ts @@ -108,4 +108,15 @@ export type Account = { * account after a switch, until that account's preferences loaded. */ isBetaUser?: boolean + + /** + * The account's subscribed labeler DIDs, cached from preferences so the + * `atproto-accept-labelers` header can be configured synchronously at + * session start, before preferences load. Eventually consistent: rewritten + * on every preferences fetch (see `saveLabelers` in + * `#/state/session/moderation`). Until the first fetch lands there is + * simply no cache entry and initial requests go out without per-account + * labeler headers. + */ + labelers?: string[] }