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 50fccd8347
commit 786155ce5b
4 changed files with 28 additions and 25 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ export function VideoPostCard({
screen: 'TempVibe', screen: 'TempVibe',
params: { params: {
feedUri: sourceFeedUri, feedUri: sourceFeedUri,
cursor: post.cid, postUri: post.uri,
}, },
}} }}
onHoverIn={onHoverIn} onHoverIn={onHoverIn}
+1 -1
View File
@@ -57,7 +57,7 @@ export type CommonNavigatorParams = {
StarterPackShort: {code: string} StarterPackShort: {code: string}
StarterPackWizard: undefined StarterPackWizard: undefined
StarterPackEdit: {rkey?: string} StarterPackEdit: {rkey?: string}
TempVibe: {feedUri: string; cursor?: string} TempVibe: {feedUri: string; postUri?: string}
} }
export type BottomTabNavigatorParams = CommonNavigatorParams & { export type BottomTabNavigatorParams = CommonNavigatorParams & {
+8 -4
View File
@@ -118,13 +118,17 @@ function YoloFeed() {
hasNextPage, hasNextPage,
isFetchingNextPage, isFetchingNextPage,
fetchNextPage, fetchNextPage,
} = usePostFeedQuery(`feedgen|${params.feedUri}`, { } = usePostFeedQuery(`feedgen|${params.feedUri}`)
initialCursor: params.cursor,
})
const videos = data?.pages.flatMap(page => let videos = data?.pages.flatMap(page =>
page.slices.flatMap(slice => slice.items), 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< const [currentSources, setCurrentSources] = useState<
[string | null, string | null, string | null] [string | null, string | null, string | null]
+9 -10
View File
@@ -61,10 +61,9 @@ export type FeedDescriptor =
export interface FeedParams { export interface FeedParams {
mergeFeedEnabled?: boolean mergeFeedEnabled?: boolean
mergeFeedSources?: string[] 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 const RQKEY_ROOT = 'post-feed'
export function RQKEY(feedDesc: FeedDescriptor, params?: FeedParams) { export function RQKEY(feedDesc: FeedDescriptor, params?: FeedParams) {
@@ -172,11 +171,10 @@ export function usePostFeedQuery(
queryKey: RQKEY(feedDesc, params), queryKey: RQKEY(feedDesc, params),
async queryFn({pageParam}: {pageParam: RQPageParam}) { async queryFn({pageParam}: {pageParam: RQPageParam}) {
logger.debug('usePostFeedQuery', {feedDesc, cursor: pageParam?.cursor}) logger.debug('usePostFeedQuery', {feedDesc, cursor: pageParam?.cursor})
console.log('PAGE', feedDesc, pageParam?.cursor) const {api, cursor} = pageParam
const cursor = pageParam?.cursor ? pageParam
let api = pageParam?.api : {
if (!api) { api: createApi({
api = createApi({
feedDesc, feedDesc,
feedParams: params || {}, feedParams: params || {},
feedTuners, feedTuners,
@@ -185,11 +183,12 @@ export function usePostFeedQuery(
userInterests, userInterests,
// Not in the query key. Reacting to it switching isn't important: // Not in the query key. Reacting to it switching isn't important:
enableFollowingToDiscoverFallback, enableFollowingToDiscoverFallback,
}) }),
cursor: undefined,
} }
try { 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. * If this is a public view, we need to check if posts fail moderation.
@@ -224,7 +223,7 @@ export function usePostFeedQuery(
throw e throw e
} }
}, },
initialPageParam: {api: undefined, cursor: params?.initialCursor}, initialPageParam: undefined,
getNextPageParam: lastPage => getNextPageParam: lastPage =>
lastPage.cursor lastPage.cursor
? { ? {