fix: use insertedAt as cursor for list (#580)
This commit is contained in:
@@ -8,7 +8,7 @@ import { useRouteParams, useRouteParamsSelector } from "~/hooks/biz/useRoutePara
|
||||
import { useAuthQuery } from "~/hooks/common"
|
||||
import { entries, useEntries } from "~/queries/entries"
|
||||
import { entryActions, useEntryIdsByFeedIdOrView } from "~/store/entry"
|
||||
import { useFolderFeedsByFeedId } from "~/store/subscription"
|
||||
import { isSubscriptionList, useFolderFeedsByFeedId } from "~/store/subscription"
|
||||
import { feedUnreadActions } from "~/store/unread"
|
||||
|
||||
export const useEntryMarkReadHandler = (entriesIds: string[]) => {
|
||||
@@ -71,6 +71,7 @@ export const useEntriesByView = ({
|
||||
view,
|
||||
...(unreadOnly === true && { read: false }),
|
||||
isArchived,
|
||||
isList: isSubscriptionList(feedId),
|
||||
}
|
||||
const query = useEntries(entriesOptions)
|
||||
|
||||
|
||||
@@ -114,15 +114,20 @@ export const useEntries = ({
|
||||
view,
|
||||
read,
|
||||
isArchived,
|
||||
isList,
|
||||
}: {
|
||||
id?: number | string
|
||||
view?: number
|
||||
read?: boolean
|
||||
isArchived?: boolean
|
||||
isList?: boolean
|
||||
}) =>
|
||||
useAuthInfiniteQuery(entries.entries({ id, view, read, isArchived }), {
|
||||
enabled: id !== undefined,
|
||||
getNextPageParam: (lastPage) => lastPage.data?.at(-1)?.entries.publishedAt,
|
||||
getNextPageParam: (lastPage) =>
|
||||
isList
|
||||
? lastPage.data?.at(-1)?.entries.insertedAt
|
||||
: lastPage.data?.at(-1)?.entries.publishedAt,
|
||||
initialPageParam: undefined,
|
||||
refetchOnWindowFocus: false,
|
||||
refetchOnReconnect: false,
|
||||
|
||||
@@ -354,3 +354,10 @@ export const getSubscriptionByFeedId = (feedId: FeedId) => {
|
||||
const state = get()
|
||||
return state.data[feedId]
|
||||
}
|
||||
|
||||
export const isSubscriptionList = (feedId?: FeedId) => {
|
||||
if (!feedId) return false
|
||||
const subscription = getSubscriptionByFeedId(feedId)
|
||||
if (!subscription) return false
|
||||
return "listId" in subscription && !!subscription.listId
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user