Use same source for pinned feeds on Home and tab/sidebars (#2235)
parent
8df4fd4d57
commit
14c77255dd
|
@ -249,6 +249,7 @@ export function usePinnedFeedsInfos(): {
|
||||||
// these requests can fail, need to filter those out
|
// these requests can fail, need to filter those out
|
||||||
try {
|
try {
|
||||||
return await queryClient.fetchQuery({
|
return await queryClient.fetchQuery({
|
||||||
|
staleTime: STALE.SECONDS.FIFTEEN,
|
||||||
queryKey: feedSourceInfoQueryKey({uri}),
|
queryKey: feedSourceInfoQueryKey({uri}),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const type = getFeedTypeFromUri(uri)
|
const type = getFeedTypeFromUri(uri)
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {FeedPage} from 'view/com/feeds/FeedPage'
|
||||||
import {HomeLoggedOutCTA} from '../com/auth/HomeLoggedOutCTA'
|
import {HomeLoggedOutCTA} from '../com/auth/HomeLoggedOutCTA'
|
||||||
import {useSetMinimalShellMode, useSetDrawerSwipeDisabled} from '#/state/shell'
|
import {useSetMinimalShellMode, useSetDrawerSwipeDisabled} from '#/state/shell'
|
||||||
import {usePreferencesQuery} from '#/state/queries/preferences'
|
import {usePreferencesQuery} from '#/state/queries/preferences'
|
||||||
|
import {usePinnedFeedsInfos, FeedSourceInfo} from '#/state/queries/feed'
|
||||||
import {UsePreferencesQueryResponse} from '#/state/queries/preferences/types'
|
import {UsePreferencesQueryResponse} from '#/state/queries/preferences/types'
|
||||||
import {emitSoftReset} from '#/state/events'
|
import {emitSoftReset} from '#/state/events'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
|
@ -21,6 +22,7 @@ import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries'
|
||||||
type Props = NativeStackScreenProps<HomeTabNavigatorParams, 'Home'>
|
type Props = NativeStackScreenProps<HomeTabNavigatorParams, 'Home'>
|
||||||
export function HomeScreen(props: Props) {
|
export function HomeScreen(props: Props) {
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
|
const {feeds: pinnedFeeds} = usePinnedFeedsInfos()
|
||||||
const {isDesktop} = useWebMediaQueries()
|
const {isDesktop} = useWebMediaQueries()
|
||||||
const [initialPage, setInitialPage] = React.useState<string | undefined>(
|
const [initialPage, setInitialPage] = React.useState<string | undefined>(
|
||||||
undefined,
|
undefined,
|
||||||
|
@ -39,11 +41,12 @@ export function HomeScreen(props: Props) {
|
||||||
loadLastActivePage()
|
loadLastActivePage()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
if (preferences && initialPage !== undefined) {
|
if (preferences && pinnedFeeds && initialPage !== undefined) {
|
||||||
return (
|
return (
|
||||||
<HomeScreenReady
|
<HomeScreenReady
|
||||||
{...props}
|
{...props}
|
||||||
preferences={preferences}
|
preferences={preferences}
|
||||||
|
pinnedFeeds={pinnedFeeds}
|
||||||
initialPage={isDesktop ? 'Following' : initialPage}
|
initialPage={isDesktop ? 'Following' : initialPage}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
@ -58,9 +61,11 @@ export function HomeScreen(props: Props) {
|
||||||
|
|
||||||
function HomeScreenReady({
|
function HomeScreenReady({
|
||||||
preferences,
|
preferences,
|
||||||
|
pinnedFeeds,
|
||||||
initialPage,
|
initialPage,
|
||||||
}: Props & {
|
}: Props & {
|
||||||
preferences: UsePreferencesQueryResponse
|
preferences: UsePreferencesQueryResponse
|
||||||
|
pinnedFeeds: FeedSourceInfo[]
|
||||||
initialPage: string
|
initialPage: string
|
||||||
}) {
|
}) {
|
||||||
const {hasSession} = useSession()
|
const {hasSession} = useSession()
|
||||||
|
@ -82,9 +87,9 @@ function HomeScreenReady({
|
||||||
}, [preferences.feeds.pinned, selectedPage])
|
}, [preferences.feeds.pinned, selectedPage])
|
||||||
|
|
||||||
const customFeeds = React.useMemo(() => {
|
const customFeeds = React.useMemo(() => {
|
||||||
const pinned = preferences.feeds.pinned
|
const pinned = pinnedFeeds
|
||||||
const feeds: FeedDescriptor[] = []
|
const feeds: FeedDescriptor[] = []
|
||||||
for (const uri of pinned) {
|
for (const {uri} of pinned) {
|
||||||
if (uri.includes('app.bsky.feed.generator')) {
|
if (uri.includes('app.bsky.feed.generator')) {
|
||||||
feeds.push(`feedgen|${uri}`)
|
feeds.push(`feedgen|${uri}`)
|
||||||
} else if (uri.includes('app.bsky.graph.list')) {
|
} else if (uri.includes('app.bsky.graph.list')) {
|
||||||
|
@ -92,7 +97,7 @@ function HomeScreenReady({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return feeds
|
return feeds
|
||||||
}, [preferences.feeds.pinned])
|
}, [pinnedFeeds])
|
||||||
|
|
||||||
const homeFeedParams = React.useMemo<FeedParams>(() => {
|
const homeFeedParams = React.useMemo<FeedParams>(() => {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue