diff --git a/src/features/inviteFriends/InviteFriendsDialogInner.tsx b/src/features/inviteFriends/InviteFriendsDialogInner.tsx index 16377c49f3..0c5673251e 100644 --- a/src/features/inviteFriends/InviteFriendsDialogInner.tsx +++ b/src/features/inviteFriends/InviteFriendsDialogInner.tsx @@ -1,4 +1,4 @@ -import {Suspense, useRef, useState} from 'react' +import {Suspense, useRef} from 'react' import {Pressable, View} from 'react-native' import type ViewShot from 'react-native-view-shot' import {setStringAsync} from 'expo-clipboard' @@ -25,6 +25,7 @@ import {IS_NATIVE} from '#/env' import {ActionButtons} from './components/ActionButtons' import {ThemedQrCard} from './components/ThemedQrCard' import {ThemePicker} from './components/ThemePicker' +import {useInviteThemeKey} from './hooks/useInviteThemeKey' import {getInviteTheme, type InviteThemeKey} from './themes' import {getInviteDisplayUrl, getInviteShareUrl} from './urls' @@ -39,7 +40,7 @@ export function InviteFriendsDialogInner({ const navigation = useNavigation() const {currentAccount} = useSession() const profileQuery = useProfileQuery({did: currentAccount?.did}) - const [themeKey, setThemeKey] = useState('day') + const [themeKey, setThemeKey] = useInviteThemeKey() const captureRef = useRef(null) const theme = getInviteTheme(themeKey) diff --git a/src/features/inviteFriends/hooks/useInviteThemeKey.ts b/src/features/inviteFriends/hooks/useInviteThemeKey.ts new file mode 100644 index 0000000000..53dff2ec8f --- /dev/null +++ b/src/features/inviteFriends/hooks/useInviteThemeKey.ts @@ -0,0 +1,14 @@ +import {device, useStorage} from '#/storage' +import {INVITE_THEMES, type InviteThemeKey} from '../themes' + +/** + * Persisted color theme for the Invite Friends QR card (APP-2409). Falls back + * to 'day' when nothing is stored or the stored key is no longer a valid + * theme. + */ +export function useInviteThemeKey() { + const [stored, setThemeKey] = useStorage(device, ['inviteFriendsThemeKey']) + const themeKey: InviteThemeKey = + stored && stored in INVITE_THEMES ? stored : 'day' + return [themeKey, setThemeKey] as const +} diff --git a/src/storage/schema.ts b/src/storage/schema.ts index 6303600343..add2e9a0a8 100644 --- a/src/storage/schema.ts +++ b/src/storage/schema.ts @@ -1,5 +1,6 @@ import {type ID as PolicyUpdate202508} from '#/components/PolicyUpdateOverlay/updates/202508/config' import {type Gif} from '#/features/gifPicker/types' +import {type InviteThemeKey} from '#/features/inviteFriends/themes' import {type Geolocation} from '#/geolocation/types' /** @@ -62,6 +63,10 @@ export type Device = { activitySubscriptionsNudged?: boolean threadgateNudged?: boolean inviteFriendsFollowersPromoDismissed?: boolean + /** + * Selected color theme for the Invite Friends QR card. + */ + inviteFriendsThemeKey?: InviteThemeKey /** * Policy update overlays. New IDs are required for each new announcement.