land on the correct feed
This commit is contained in:
@@ -132,6 +132,13 @@ export function StepFinished() {
|
|||||||
})(),
|
})(),
|
||||||
requestNotificationsPermission('AfterOnboarding'),
|
requestNotificationsPermission('AfterOnboarding'),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
if (usedStarterPack) {
|
||||||
|
setUsedStarterPack({
|
||||||
|
...usedStarterPack,
|
||||||
|
initialFeed: starterPack?.feeds?.[0].uri ?? undefined,
|
||||||
|
})
|
||||||
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
logger.info(`onboarding: bulk save failed`)
|
logger.info(`onboarding: bulk save failed`)
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
@@ -152,7 +159,6 @@ export function StepFinished() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
setSaving(false)
|
setSaving(false)
|
||||||
setUsedStarterPack(undefined)
|
|
||||||
dispatch({type: 'finish'})
|
dispatch({type: 'finish'})
|
||||||
onboardDispatch({type: 'finish'})
|
onboardDispatch({type: 'finish'})
|
||||||
track('OnboardingV2:StepFinished:End')
|
track('OnboardingV2:StepFinished:End')
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ export const schema = z.object({
|
|||||||
.object({
|
.object({
|
||||||
uri: z.string(),
|
uri: z.string(),
|
||||||
cid: z.string(),
|
cid: z.string(),
|
||||||
|
initialFeed: z.string().optional(),
|
||||||
})
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React from 'react'
|
|||||||
|
|
||||||
import * as persisted from '#/state/persisted'
|
import * as persisted from '#/state/persisted'
|
||||||
|
|
||||||
type StateContext = {uri: string; cid: string} | undefined
|
type StateContext = {uri: string; cid: string; initialFeed?: string} | undefined
|
||||||
type SetContext = (v: StateContext) => void
|
type SetContext = (v: StateContext) => void
|
||||||
|
|
||||||
const stateContext = React.createContext<StateContext>(undefined)
|
const stateContext = React.createContext<StateContext>(undefined)
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ import {
|
|||||||
import {useSelectedFeed, useSetSelectedFeed} from '#/state/shell/selected-feed'
|
import {useSelectedFeed, useSetSelectedFeed} from '#/state/shell/selected-feed'
|
||||||
import {useOTAUpdates} from 'lib/hooks/useOTAUpdates'
|
import {useOTAUpdates} from 'lib/hooks/useOTAUpdates'
|
||||||
import {HomeTabNavigatorParams, NativeStackScreenProps} from 'lib/routes/types'
|
import {HomeTabNavigatorParams, NativeStackScreenProps} from 'lib/routes/types'
|
||||||
|
import {
|
||||||
|
useSetUsedStarterPack,
|
||||||
|
useUsedStarterPack,
|
||||||
|
} from 'state/preferences/starter-pack'
|
||||||
import {FeedPage} from 'view/com/feeds/FeedPage'
|
import {FeedPage} from 'view/com/feeds/FeedPage'
|
||||||
import {Pager, PagerRef, RenderTabBarFnProps} from 'view/com/pager/Pager'
|
import {Pager, PagerRef, RenderTabBarFnProps} from 'view/com/pager/Pager'
|
||||||
import {CustomFeedEmptyState} from 'view/com/posts/CustomFeedEmptyState'
|
import {CustomFeedEmptyState} from 'view/com/posts/CustomFeedEmptyState'
|
||||||
@@ -67,6 +71,8 @@ function HomeScreenReady({
|
|||||||
const maybeFoundIndex = allFeeds.indexOf(rawSelectedFeed)
|
const maybeFoundIndex = allFeeds.indexOf(rawSelectedFeed)
|
||||||
const selectedIndex = Math.max(0, maybeFoundIndex)
|
const selectedIndex = Math.max(0, maybeFoundIndex)
|
||||||
const selectedFeed = allFeeds[selectedIndex]
|
const selectedFeed = allFeeds[selectedIndex]
|
||||||
|
const usedStarterPack = useUsedStarterPack()
|
||||||
|
const setUsedStarterPack = useSetUsedStarterPack()
|
||||||
|
|
||||||
useSetTitle(pinnedFeedInfos[selectedIndex]?.displayName)
|
useSetTitle(pinnedFeedInfos[selectedIndex]?.displayName)
|
||||||
useOTAUpdates()
|
useOTAUpdates()
|
||||||
@@ -74,14 +80,25 @@ function HomeScreenReady({
|
|||||||
const pagerRef = React.useRef<PagerRef>(null)
|
const pagerRef = React.useRef<PagerRef>(null)
|
||||||
const lastPagerReportedIndexRef = React.useRef(selectedIndex)
|
const lastPagerReportedIndexRef = React.useRef(selectedIndex)
|
||||||
React.useLayoutEffect(() => {
|
React.useLayoutEffect(() => {
|
||||||
|
let initialIndex = selectedIndex
|
||||||
|
if (usedStarterPack) {
|
||||||
|
initialIndex = allFeeds.findIndex(
|
||||||
|
f => f === `feedgen|${usedStarterPack.initialFeed}`,
|
||||||
|
)
|
||||||
|
setUsedStarterPack(undefined)
|
||||||
|
}
|
||||||
|
|
||||||
// Since the pager is not a controlled component, adjust it imperatively
|
// Since the pager is not a controlled component, adjust it imperatively
|
||||||
// if the selected index gets out of sync with what it last reported.
|
// if the selected index gets out of sync with what it last reported.
|
||||||
// This is supposed to only happen on the web when you use the right nav.
|
// This is supposed to only happen on the web when you use the right nav.
|
||||||
if (selectedIndex !== lastPagerReportedIndexRef.current) {
|
if (initialIndex !== selectedIndex) {
|
||||||
|
lastPagerReportedIndexRef.current = initialIndex
|
||||||
|
pagerRef.current?.setPage(initialIndex, 'desktop-sidebar-click')
|
||||||
|
} else if (selectedIndex !== lastPagerReportedIndexRef.current) {
|
||||||
lastPagerReportedIndexRef.current = selectedIndex
|
lastPagerReportedIndexRef.current = selectedIndex
|
||||||
pagerRef.current?.setPage(selectedIndex, 'desktop-sidebar-click')
|
pagerRef.current?.setPage(selectedIndex, 'desktop-sidebar-click')
|
||||||
}
|
}
|
||||||
}, [selectedIndex])
|
}, [selectedIndex, usedStarterPack, setUsedStarterPack, allFeeds])
|
||||||
|
|
||||||
const {hasSession} = useSession()
|
const {hasSession} = useSession()
|
||||||
const setMinimalShellMode = useSetMinimalShellMode()
|
const setMinimalShellMode = useSetMinimalShellMode()
|
||||||
|
|||||||
Reference in New Issue
Block a user