Live updates from the server reach the pages through the contexts declared here. Three hold state: votes, likes, deletions and counts in one, the chat in another, who is online in the third, split so that a feed doesn't re-render with every chat message or presence change. The fourth passes on events, each change to a dump, playlist, comment or profile and each notification, to the components that subscribe to their kind. WSProvider fills them all from its WebSocket, and components read them with useWS, useWSChat, useWSPresence and useWSEvent.

Functions

f
createWSEventBus(): WSEventBus

Returns a bus with no subscribers.

Interfaces

I
ChatError

Tells the user the server refused their chat edit or delete. WSProvider sets it as chatError, and ChatModal shows it for a few seconds.

I
ChatReplyTarget

Quotes the message a chat message replies to. ChatModal shows it in the reply bar once the user picks it, and it stays on the pending message so the quote shows before the server's echo. Only id goes to the server.

I
CommentEvent

Keeps comment threads and comment counts live. WSProvider emits it as a comment event on each comment_* message; the Dump page applies it to its thread, and useDumpListSync to the counts on dump cards.

I
DumpEvent

Keeps every dump on screen up to date. WSProvider emits it as a dump event on each dump_created and dump_updated; useDumpListSync applies it to lists, and the Dump page to its dump. A dump that turns public comes created to those who couldn't see it.

I
PendingChatMessage

Shows a chat message the moment the user sends it, and lets them retry it if it fails. WSProvider holds it until the server echoes the message back, and ChatModal shows it, as PendingItem, after the messages the server has.

I
PlaylistEvent

Keeps the playlists on screen up to date, in lists, on a playlist's page and on a dump's page. WSProvider emits it as a playlist event on each playlist_* message; lists apply it through usePlaylistListSync, a playlist's page through usePlaylist. Which fields are set depends on type.

I
RelatedEvent

Keeps the related dumps on a dump's page live. WSProvider emits it as a related event on each dump_related_changed, and the Dump page fetches its related dumps again when dumpIds names its dump.

I
UserEvent

Keeps a user's profile, and their name on what they posted, up to date. WSProvider emits it as a user event on each user_updated, which the server sends on any change to a profile; useProfile applies it to the profile page, and the list sync hooks to the names on cards.

I
VoteEvent

Keeps a user's upvoted list live, on their profile's overview and tab. WSProvider emits it as a vote event on each votes_update, and useUpvotedList adds or drops the dump.

I
WSChatContextValue

Carries the chat's live side, which ChatModal lays over the history it fetches and the chat buttons show as a badge. WSProvider provides it through WSChatContext, and components read it with useWSChat. The socket sends chat only to signed-in users, so for a visitor it stays empty.

I
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.

I
WSEventBus

Delivers WSEvents to their subscribers. WSProvider creates one with createWSEventBus and emits on it as messages arrive; components subscribe through WSEventsContext, and tests emit on their own.

I
WSEvents

The events WSProvider passes on, by kind, to the components that subscribe with useWSEvent. Unlike the state of WSContext, every event reaches every subscriber, however many arrive before the next render. categories says the categories changed, and carries nothing.

I
WSPresenceContextValue

Carries who is online, for PresenceRow. WSProvider provides it through WSPresenceContext, and components read it with useWSPresence.

Variables

v
defaultWSChatValue: WSChatContextValue

Lets a component render outside WSProvider, with an empty chat.

v
defaultWSPresenceValue: WSPresenceContextValue

Lets a component render outside WSProvider, with nobody online.

v
defaultWSValue: WSContextValue

Lets a component render outside WSProvider, as if the socket were connecting.

v
WSChatContext: React.Context<WSChatContextValue>

Carries the chat's live stream and read state. Read it with useWSChat.

v
WSContext: React.Context<WSContextValue>

Carries the live state pages lay over what they fetched: the connection, the votes and likes, and the latest event of each kind. Read it with useWS.

v
WSEventsContext: React.Context<Pick<WSEventBus, "subscribe">>

Carries the bus WSProvider emits its events on, for useWSEvent. Outside WSProvider, it is a bus no one emits on.

v
WSPresenceContext: React.Context<WSPresenceContextValue>

Carries who is online. Read it with useWSPresence.