fix(entry-column): pre-render cached entries
Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
parent
120cf43bcd
commit
5065c8e52d
|
|
@ -49,6 +49,7 @@ export const useEntryMarkReadHandler = (entriesIds: string[]) => {
|
|||
return
|
||||
}, [feedView, handleMarkReadInRange, handleRenderAsRead, renderAsRead, scrollMarkUnread])
|
||||
}
|
||||
const anyString = [] as string[]
|
||||
export const useEntriesByView = ({
|
||||
onReset,
|
||||
isArchived,
|
||||
|
|
@ -103,16 +104,15 @@ export const useEntriesByView = ({
|
|||
setPauseQuery(hasUpdate)
|
||||
}, [hasUpdate])
|
||||
|
||||
const remoteEntryIds = useMemo(
|
||||
() =>
|
||||
// FIXME The back end should not return duplicate data, and the front end the unique id here.
|
||||
[
|
||||
...new Set(
|
||||
query.data?.pages?.map((page) => page.data?.map((entry) => entry.entries.id)).flat(),
|
||||
).values(),
|
||||
] as string[],
|
||||
[query.data?.pages],
|
||||
)
|
||||
const remoteEntryIds = useMemo(() => {
|
||||
if (!query.data?.pages) return void 0
|
||||
// FIXME The back end should not return duplicate data, and the front end the unique id here.
|
||||
return [
|
||||
...new Set(
|
||||
query.data?.pages?.map((page) => page.data?.map((entry) => entry.entries.id)).flat(),
|
||||
).values(),
|
||||
] as string[]
|
||||
}, [query.data?.pages])
|
||||
|
||||
const currentEntries = useEntryIdsByFeedIdOrView(isAllFeeds ? view : folderIds || feedId!, {
|
||||
unread: unreadOnly,
|
||||
|
|
@ -126,7 +126,7 @@ export const useEntriesByView = ({
|
|||
// then we have no way to incrementally update the data.
|
||||
// We need to add an interface to incrementally update the data based on the version hash.
|
||||
|
||||
const entryIds = remoteEntryIds || currentEntries
|
||||
const entryIds: string[] = remoteEntryIds || currentEntries || anyString
|
||||
|
||||
// in unread only entries only can grow the data, but not shrink
|
||||
// so we memo this previous data to avoid the flicker
|
||||
|
|
|
|||
Loading…
Reference in New Issue