interface WSContextValue

Carries the live state but the chat and presence, for pages to lay over what they fetched. WSProvider provides it through WSContext, and components read it with useWS. The changes to single items come as events instead, through WSEventsContext. After a reconnect, connectionEpoch tells pages to fetch what they missed.

Properties

wsStatus: "connecting" | "connected" | "disconnected"
wsErrorMessage: string | null

Set while the socket is down, for the banner that says so.

voteCounts: Record<string, number>

Shows vote counts live. It holds, by dump id, the counts the server pushed or this tab changed optimistically; a dump missing from it shows its fetched voteCount.

myVotes: Set<string>

Marks the dumps this user upvoted, for their vote buttons. The server's welcome resets it on every connection.

likeCounts: Record<string, number>

As voteCounts, for comments.

myLikes: Set<string>

As myVotes, for comments.

Shows new dumps on the index as they are posted, merged by date with the feed Index fetched. It holds, newest first and at most 100, the ones the server announced this session, which are public, and the ones this user posted, which may be private.

deletedDumpIds: Set<string>

Takes deleted dumps off every list at once. It holds the dumps deleted this session, or made private by someone else; a dump made public again leaves it.

Takes deleted playlists off every list at once, as deletedDumpIds does dumps.

Drives the bell's badge. It comes from the welcome, then each new notification counts it up, and notifications_read zeroes it.

Tells pages to fetch again what they missed while the socket was down. It goes up on each reconnect, never on the first connection.

Keeps the Follow buttons right when the user follows or unfollows in another tab. It goes up on every follow change, in any tab, and FollowProvider fetches the follow status again.

castVote: (
dumpId: string,
shownCount?: number
) => void

Upvotes a dump at once and sends vote_cast. The server's answer confirms or reverts it, and so does a timeout of 5 s, which covers a closed socket. shownCount is the count on screen, used when voteCounts has none yet. Does nothing when the user already voted.

removeVote: (
dumpId: string,
shownCount?: number
) => void

Withdraws an upvote, as WSContextValue.castVote casts one.

castCommentLike: (
commentId: string,
shownCount?: number
) => void

Likes a comment, as WSContextValue.castVote upvotes a dump.

removeCommentLike: (
commentId: string,
shownCount?: number
) => void

Withdraws a like, as WSContextValue.castVote casts a vote.

injectDump: (dump: Dump) => void

Shows a dump this user just posted on the index without waiting for its broadcast. DumpCreateModal calls it, and it adds the dump to recentDumps.

Zeroes the bell's count, once the notifications page has marked them read on the server.