Keeps the chat composer's unsent message when the chat modal closes or the
tab reloads. It lives in sessionStorage, per user; ChatModal reads it on
open and writes it on every change.
f
readDraft(userId: string | undefined): StoredDraft
Returns the stored draft of userId, or an empty one when there is none,
userId is undefined, or storage is blocked.
f
writeDraft(): void
userId: string | undefined,
value: StoredDraft
Stores value as the draft of userId, or removes it when it has neither
text nor a reply target. Does nothing when userId is undefined.
I
StoredDraft
Returned by readDraft to ChatModal, which passes it back to
writeDraft.
Usage
import * as mod from "src/utils/chat/draft.ts";