Use same source for pinned feeds on Home and tab/sidebars (#2235)

zio/stable
Eric Bailey 2023-12-18 16:42:37 -06:00 committed by GitHub
parent 8df4fd4d57
commit 14c77255dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -249,6 +249,7 @@ export function usePinnedFeedsInfos(): {
// these requests can fail, need to filter those out
try {
return await queryClient.fetchQuery({
staleTime: STALE.SECONDS.FIFTEEN,
queryKey: feedSourceInfoQueryKey({uri}),
queryFn: async () => {
const type = getFeedTypeFromUri(uri)

View File

@ -12,6 +12,7 @@ import {FeedPage} from 'view/com/feeds/FeedPage'
import {HomeLoggedOutCTA} from '../com/auth/HomeLoggedOutCTA'
import {useSetMinimalShellMode, useSetDrawerSwipeDisabled} from '#/state/shell'
import {usePreferencesQuery} from '#/state/queries/preferences'
import {usePinnedFeedsInfos, FeedSourceInfo} from '#/state/queries/feed'
import {UsePreferencesQueryResponse} from '#/state/queries/preferences/types'
import {emitSoftReset} from '#/state/events'
import {useSession} from '#/state/session'
@ -21,6 +22,7 @@ import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries'
type Props = NativeStackScreenProps<HomeTabNavigatorParams, 'Home'>
export function HomeScreen(props: Props) {
const {data: preferences} = usePreferencesQuery()
const {feeds: pinnedFeeds} = usePinnedFeedsInfos()
const {isDesktop} = useWebMediaQueries()
const [initialPage, setInitialPage] = React.useState<string | undefined>(
undefined,
@ -39,11 +41,12 @@ export function HomeScreen(props: Props) {
loadLastActivePage()
}, [])
if (preferences && initialPage !== undefined) {
if (preferences && pinnedFeeds && initialPage !== undefined) {
return (
<HomeScreenReady
{...props}
preferences={preferences}
pinnedFeeds={pinnedFeeds}
initialPage={isDesktop ? 'Following' : initialPage}
/>
)
@ -58,9 +61,11 @@ export function HomeScreen(props: Props) {
function HomeScreenReady({
preferences,
pinnedFeeds,
initialPage,
}: Props & {
preferences: UsePreferencesQueryResponse
pinnedFeeds: FeedSourceInfo[]
initialPage: string
}) {
const {hasSession} = useSession()
@ -82,9 +87,9 @@ function HomeScreenReady({
}, [preferences.feeds.pinned, selectedPage])
const customFeeds = React.useMemo(() => {
const pinned = preferences.feeds.pinned
const pinned = pinnedFeeds
const feeds: FeedDescriptor[] = []
for (const uri of pinned) {
for (const {uri} of pinned) {
if (uri.includes('app.bsky.feed.generator')) {
feeds.push(`feedgen|${uri}`)
} else if (uri.includes('app.bsky.graph.list')) {
@ -92,7 +97,7 @@ function HomeScreenReady({
}
}
return feeds
}, [preferences.feeds.pinned])
}, [pinnedFeeds])
const homeFeedParams = React.useMemo<FeedParams>(() => {
return {