/** * Shows a user's new avatar everywhere as soon as they change it, without a * reload. `WSProvider` fills this context from `user_updated` messages, and * `Avatar` reads it. * * @module */ import { createContext } from "react"; /** * Set by `WSProvider` for a user whose profile changed, and read by `Avatar`, * where it wins over the possibly stale props the page fetched. */ export interface AvatarOverride { hasAvatar: boolean; /** * The user's `updatedAt` in ms, or the arrival time without one. It busts the * cached image. */ version: number; } /** * Shows changed avatars without a reload, as an {@link AvatarOverride} by user * id. It is apart from `WSContext`, so the many avatars of a page don't * re-render on every vote or comment. */ export const AvatarOverrideContext: React.Context< Record > = createContext< Record >({});