Skip to main content

Module draft

Module draft 

Expand description

A draft is kept, and shown where the conversation is listed.

What a person was writing and has not sent is theirs: it survives the window closing, it is there when they come back to that channel or that person, and the list of conversations says so before they open it — a draft you cannot find is a draft you have lost.

Two pieces here. DraftBook is the rule: a draft is per conversation, a blank draft is no draft, and sending removes the draft only while it is still the one that was sent (a word typed while the send was in flight is not thrown away). preview is the line a listing draws: the first line of the body, its runs of whitespace folded to one space, elided at a grapheme boundary, prefixed “Draft: “.

Persistence is the app’s: a draft belongs on the person’s own record (theirs, on their other devices), never in the shared conversation. This module holds the rule set, not the storage.

Structs§

DraftBook
The drafts a person has, by conversation key.

Constants§

DRAFT_PREVIEW_CHARS
How much of a draft a listing shows before eliding.

Functions§

line
The line a conversation’s row carries for a draft: “Draft: see you at 8”. None when the body has nothing in it.
preview
The first line of a draft body, whitespace folded and elided: what a conversation list shows under a name. None when there is nothing to say (a body of spaces is not a draft).