diff --git a/src/screens/StarterPack/Main/index.tsx b/src/screens/StarterPack/Main/index.tsx index 221e9b6b39..14269f1ae3 100644 --- a/src/screens/StarterPack/Main/index.tsx +++ b/src/screens/StarterPack/Main/index.tsx @@ -10,9 +10,11 @@ import {makeProfileLink} from 'lib/routes/links' import {CommonNavigatorParams, NavigationProp} from 'lib/routes/types' import {shareUrl} from 'lib/sharing' import {isWeb} from 'platform/detection' +import {useSetUsedStarterPack} from 'state/preferences/starter-pack' import {useResolveDidQuery} from 'state/queries/resolve-uri' import {useStarterPackQuery} from 'state/queries/useStarterPackQuery' import {useSession} from 'state/session' +import {useLoggedOutViewControls} from 'state/shell/logged-out' import {PagerWithHeader} from 'view/com/pager/PagerWithHeader' import {ProfileSubpageHeader} from 'view/com/profile/ProfileSubpageHeader' import {CenteredView} from 'view/com/util/Views' @@ -110,6 +112,8 @@ function Header({ const navigation = useNavigation() const {currentAccount} = useSession() const qrCodeDialogControl = useDialogControl() + const setUsedStarterPack = useSetUsedStarterPack() + const {setShowLoggedOut} = useLoggedOutViewControls() const {record, creator} = starterPack const isOwn = creator.did === currentAccount?.did @@ -136,9 +140,10 @@ function Header({ variant="solid" color="secondary" size="small" - onPress={() => - navigation.replace('StarterPackLanding', {name, rkey}) - }> + onPress={() => { + setUsedStarterPack({uri: starterPack.uri}) + setShowLoggedOut(true) + }}> Debug diff --git a/src/state/persisted/schema.ts b/src/state/persisted/schema.ts index e32a9979e4..19304b5cbe 100644 --- a/src/state/persisted/schema.ts +++ b/src/state/persisted/schema.ts @@ -91,7 +91,7 @@ export const schema = z.object({ usedStarterPack: z .object({ uri: z.string(), - cid: z.string(), + cid: z.string().optional(), initialFeed: z.string().optional(), }) .optional(), diff --git a/src/state/preferences/starter-pack.tsx b/src/state/preferences/starter-pack.tsx index 33fa190869..703080d7c0 100644 --- a/src/state/preferences/starter-pack.tsx +++ b/src/state/preferences/starter-pack.tsx @@ -2,7 +2,9 @@ import React from 'react' import * as persisted from '#/state/persisted' -type StateContext = {uri: string; cid: string; initialFeed?: string} | undefined +type StateContext = + | {uri: string; cid?: string; initialFeed?: string} + | undefined type SetContext = (v: StateContext) => void const stateContext = React.createContext(undefined) diff --git a/src/view/com/auth/LoggedOut.tsx b/src/view/com/auth/LoggedOut.tsx index c8c81dd771..6f4dac4ccd 100644 --- a/src/view/com/auth/LoggedOut.tsx +++ b/src/view/com/auth/LoggedOut.tsx @@ -18,6 +18,7 @@ import { } from '#/state/shell/logged-out' import {useSetMinimalShellMode} from '#/state/shell/minimal-mode' import {NavigationProp} from 'lib/routes/types' +import {useUsedStarterPack} from 'state/preferences/starter-pack' import {ErrorBoundary} from '#/view/com/util/ErrorBoundary' import {Text} from '#/view/com/util/text/Text' import {Login} from '#/screens/Login' @@ -28,6 +29,7 @@ enum ScreenState { S_LoginOrCreateAccount, S_Login, S_CreateAccount, + S_StarterPack, } export function LoggedOut({onDismiss}: {onDismiss?: () => void}) { @@ -36,9 +38,12 @@ export function LoggedOut({onDismiss}: {onDismiss?: () => void}) { const pal = usePalette('default') const setMinimalShellMode = useSetMinimalShellMode() const {screen} = useAnalytics() + const usedStarterPack = useUsedStarterPack() const {requestedAccountSwitchTo} = useLoggedOutView() const [screenState, setScreenState] = React.useState( - requestedAccountSwitchTo + usedStarterPack?.uri + ? ScreenState.S_StarterPack + : requestedAccountSwitchTo ? requestedAccountSwitchTo === 'new' ? ScreenState.S_CreateAccount : ScreenState.S_Login