Partial revert, just filter posts to start at index

This commit is contained in:
Eric Bailey
2025-01-16 15:31:42 -06:00
parent 5225558303
commit 3316de975e
4 changed files with 28 additions and 25 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ export function VideoPostCard({
screen: 'TempVibe',
params: {
feedUri: sourceFeedUri,
cursor: post.cid,
postUri: post.uri,
},
}}
onHoverIn={onHoverIn}
+1 -1
View File
@@ -57,7 +57,7 @@ export type CommonNavigatorParams = {
StarterPackShort: {code: string}
StarterPackWizard: undefined
StarterPackEdit: {rkey?: string}
TempVibe: {feedUri: string; cursor?: string}
TempVibe: {feedUri: string; postUri?: string}
}
export type BottomTabNavigatorParams = CommonNavigatorParams & {
+8 -4
View File
@@ -118,13 +118,17 @@ function YoloFeed() {
hasNextPage,
isFetchingNextPage,
fetchNextPage,
} = usePostFeedQuery(`feedgen|${params.feedUri}`, {
initialCursor: params.cursor,
})
} = usePostFeedQuery(`feedgen|${params.feedUri}`)
const videos = data?.pages.flatMap(page =>
let videos = data?.pages.flatMap(page =>
page.slices.flatMap(slice => slice.items),
)
const startingVideoIndex = videos?.findIndex(video => {
return video.post.uri === params.postUri
})
if (videos && startingVideoIndex && startingVideoIndex > -1) {
videos = videos.slice(startingVideoIndex)
}
const [currentSources, setCurrentSources] = useState<
[string | null, string | null, string | null]
+18 -19
View File
@@ -61,10 +61,9 @@ export type FeedDescriptor =
export interface FeedParams {
mergeFeedEnabled?: boolean
mergeFeedSources?: string[]
initialCursor?: string
}
type RQPageParam = {cursor: string | undefined; api?: FeedAPI} | undefined
type RQPageParam = {cursor: string | undefined; api: FeedAPI} | undefined
export const RQKEY_ROOT = 'post-feed'
export function RQKEY(feedDesc: FeedDescriptor, params?: FeedParams) {
@@ -172,24 +171,24 @@ export function usePostFeedQuery(
queryKey: RQKEY(feedDesc, params),
async queryFn({pageParam}: {pageParam: RQPageParam}) {
logger.debug('usePostFeedQuery', {feedDesc, cursor: pageParam?.cursor})
console.log('PAGE', feedDesc, pageParam?.cursor)
const cursor = pageParam?.cursor
let api = pageParam?.api
if (!api) {
api = createApi({
feedDesc,
feedParams: params || {},
feedTuners,
agent,
// Not in the query key because they don't change:
userInterests,
// Not in the query key. Reacting to it switching isn't important:
enableFollowingToDiscoverFallback,
})
}
const {api, cursor} = pageParam
? pageParam
: {
api: createApi({
feedDesc,
feedParams: params || {},
feedTuners,
agent,
// Not in the query key because they don't change:
userInterests,
// Not in the query key. Reacting to it switching isn't important:
enableFollowingToDiscoverFallback,
}),
cursor: undefined,
}
try {
const res = await api!.fetch({cursor, limit: fetchLimit})
const res = await api.fetch({cursor, limit: fetchLimit})
/*
* If this is a public view, we need to check if posts fail moderation.
@@ -224,7 +223,7 @@ export function usePostFeedQuery(
throw e
}
},
initialPageParam: {api: undefined, cursor: params?.initialCursor},
initialPageParam: undefined,
getNextPageParam: lastPage =>
lastPage.cursor
? {