feat(mobile): use insertedBefore for mark above read

This commit is contained in:
DIYgod 2025-07-05 16:21:57 +08:00
parent a17db88b60
commit 47bfc49dad
No known key found for this signature in database
4 changed files with 17 additions and 5 deletions

View File

@ -31,7 +31,8 @@ export const EntryListContentArticle = ({
[playingAudioUrl, entryIds],
)
const { fetchNextPage, isFetching, refetch, isRefetching, hasNextPage } = useEntries()
const { fetchNextPage, isFetching, refetch, isRefetching, hasNextPage, fetchedTime } =
useEntries()
const renderItem = useCallback(
({ item: id, extraData }: ListRenderItemInfo<string>) => (
@ -41,8 +42,8 @@ export const EntryListContentArticle = ({
)
const ListFooterComponent = useMemo(
() => (hasNextPage ? <EntryItemSkeleton /> : <EntryListFooter />),
[hasNextPage],
() => (hasNextPage ? <EntryItemSkeleton /> : <EntryListFooter fetchedTime={fetchedTime} />),
[hasNextPage, fetchedTime],
)
const { onScroll: hackOnScroll, ref, style: hackStyle } = usePagerListPerformanceHack()

View File

@ -9,7 +9,7 @@ import { useColor } from "@/src/theme/colors"
import { getFetchEntryPayload, useSelectedFeed, useSelectedView } from "../screen/atoms"
import { ItemSeparator } from "./ItemSeparator"
export const EntryListFooter = () => {
export const EntryListFooter = ({ fetchedTime }: { fetchedTime?: number }) => {
const { t } = useTranslation()
const selectedView = useSelectedView()
const selectedFeed = useSelectedFeed()
@ -26,6 +26,7 @@ export const EntryListFooter = () => {
unreadSyncService.markBatchAsRead({
view: selectedView,
filter: payload,
time: fetchedTime ? { insertedBefore: fetchedTime } : undefined,
excludePrivate: getHideAllReadSubscriptions(),
})
}
@ -42,7 +43,7 @@ export const EntryListFooter = () => {
)
}
export const GridEntryListFooter = () => {
export const GridEntryListFooter = ({ fetchedTime }: { fetchedTime?: number }) => {
const { t } = useTranslation()
const selectedView = useSelectedView()
const selectedFeed = useSelectedFeed()
@ -56,6 +57,7 @@ export const GridEntryListFooter = () => {
unreadSyncService.markBatchAsRead({
view: selectedView,
filter: payload,
time: fetchedTime ? { insertedBefore: fetchedTime } : undefined,
excludePrivate: getHideAllReadSubscriptions(),
})
}

View File

@ -169,6 +169,13 @@ function useRemoteEntries(props?: UseEntriesProps): UseEntriesReturn {
const query = useEntriesQuery(props?.active ? { ...payload, ...options } : undefined)
const [fetchedTime, setFetchedTime] = useState<number>()
useEffect(() => {
if (!query.isFetching) {
setFetchedTime(Date.now())
}
}, [query.isFetching])
const refetch = useCallback(async () => void query.refetch(), [query])
const fetchNextPage = useCallback(async () => void query.fetchNextPage(), [query])
const entriesIds = useMemo(() => {
@ -200,6 +207,7 @@ function useRemoteEntries(props?: UseEntriesProps): UseEntriesReturn {
isFetching: query.isFetching,
hasNextPage: query.hasNextPage,
error: query.isError ? query.error : null,
fetchedTime,
}
}

View File

@ -116,6 +116,7 @@ class UnreadSyncService {
listId?: string
feedIdList?: string[]
inboxId?: string
insertedBefore?: number
} | null
time?: PublishAtTimeRangeFilter | InsertedBeforeTimeRangeFilter
excludePrivate: boolean