Keeps a page's list of dumps in step with the socket: the dumps deleted, edited and posted, their comment counts, and their posters' names.

Functions

f
useDumpListSync(
items: Dump[],
setDumps: (fn: (prev: Dump[]) => Dump[]) => void,
options?: DumpListSyncOptions
): void

Applies the socket's dump, comment and user events to items, the loaded list, which setDumps updates. A deleted dump is removed, an edited one is replaced in place, one gone private leaves unless isOwner, and a new or returning one is added as belongs and addNew say. A new or deleted comment moves its dump's commentCount, and a renamed user's dumps take their new name.

Interfaces

I
DumpListSyncOptions

Passed to useDumpListSync by the lists that need more than edits and deletions.

  • addNew: boolean

    Also adds a dump belongs accepts that the list never held, where the newest-first order puts it among the dumps loaded: a new one first. One older than all of them is left to the next pages. For the lists sorted by createdAt: the index's feed, a profile's dumps, the followed users'.

  • belongs: (dump: Dump) => boolean

    Which dumps the list may hold. A dump that left it, as by turning private, comes back where it was when it returns and this accepts it. Without it, the list never gains a dump.

  • isOwner: boolean

    The list holds the viewer's own private dumps, as their profile, the index and the search do, so that one they make private stays. Only its poster hears of a private dump's edits.