English
Topic 19. The conversation: a message store with optimistic sending, history paging, the composer and attachments
Goal: build the conversation view: a message store that shows sent messages at once and retries failed ones, loads older pages while scrolling up, edits, deletes and marks messages as read; the message list with day separators, grouping, replies and a context menu; the composer with replies, editing and attachments; and the conversation page that puts them together.
Where we are
The heart of the messenger on the client (Fig. 19.1). After this topic users can talk — but they see each other's messages only after reopening a chat; topic 20 makes them arrive live.
Fig. 19.1. The conversation and its parts
- Starting point: topic 18 — the chat list, new chats and the discover page work; 21 tests pass.
- At the end of the topic a chat opens from the list; messages are sent, replied to, edited, deleted, copied and paged; files are attached by the paperclip, by pasting or by dropping them. 38 tests pass.
Steps
- The message store — a store per component · optimistic sending · retry · merging by id · paging · read position · tests
- The message list — rows with day separators and groups · replies · the context menu · scroll anchoring · attachments
- The composer — two-way inputs · Enter and Shift+Enter · replies and editing · uploads · component tests
- The conversation page — route input · loading a chat · marking as read · drag and drop · joining a public chat
- Checkpoint — what must work, self-check questions and exercises
Materials
- Course slides, part 4, Real time and the TypeScript client (slides "A signal store", "One message, end to end")
messages.store.ts,messages.store.spec.tsfeatures/conversation/Docs/HttpApi.md– paging and limits,Docs/Testing.md– the client tests