Makes every list the API serves a page at a time work the same way. Each is a
PagedList, whose next page useLoadMore appends, and this module
reads its pages.
Checks whether list has a next page to load now, which useLoadMore
requires and useInfiniteScroll takes as enabled. A list not loaded yet
is null.
Returns the list holding only its first page, items.
Returns a setter of a list's items as a setter of the list, for the sync hooks, which edit items only.
Returns url asking for page page, limit items long.
Returns the first page res answers as a list, or an empty list when the
server refuses it. The profile pages read their lists with it beside the
user, whose failure alone fails the page.
Returns the page res answers, its items deserialized.
Fetches pages 1 to pages of a list again, and resolves to their items,
each once, and whether more follow. An item added between two pages'
fetches shifts the later page by one, which would list an item twice. A
live list calls it after a reconnection, through usePagedList's resync
or, for the search's dumps, directly; it rejects when a page fails.
Returns the list as useFeedCache's cached restores it.
Returns items, newest first, with item where its createdAt puts it,
as withInOrder does. useDumpListSync puts a new or newly visible
dump in a list with it.
Returns items with item first, or items as they are when it is already
there, as when a list's own echo of a new item arrives after it.
Returns items, in the order of compare as the API pages them, with
item where that order puts it: before the first item that doesn't come
before it. An item that comes after every one loaded is left to a later
page, and items returned as they are, as they are when item is already
there. usePlaylistListSync puts a new, newly visible or risen playlist in
a list with it, whatever its order.
Held for a list by usePagedList, or by a page that loads it along with
more, as the search page does. useLoadMore loads the pages after page.
- hasMore: boolean
- items: T[]
- loadingMore: boolean
-
page: number
Loading more carries on from this page, the last loaded.
Usage
import * as mod from "src/utils/feed/pagedList.ts";