src/activity/model.ts defines what the notify service returns and converts it into the ActivityPage the screens render. It is pure: no fetch and no clock. The UTC offset it groups days by is an argument.
Wire types
Snapshot is "the canonical notification state returned by reads and writes":
Part | Fields |
|---|---|
root |
|
|
|
|
|
|
|
NotificationEvent: feedEventId, eventAtMs, reason, eventType, author {uid, name, icon}, target {uid, path, name}, commentId, optional threadRoot, sourceId, citationType (d, c or null). The comment notes that "notify does not currently supply snippet text".
NotifyAction, "Mobile's supported notification mutations":
{type: "mark-event-read", eventId, eventAtMs}
{type: "mark-all-read", markAllReadAtMs}
{type: "set-config", email, createdAtMs}
{type: "resend-config-verification", createdAtMs}
{type: "remove-config"}
Validation
parseSnapshot(body) checks every field above once, "at the HTTP boundary, before presenting or trusting ownership fields": types, finite numbers, non-negative event times, string-or-null fields, the citationType values. Any miss throws The notification server sent an invalid inbox. A malformed answer is therefore a failure, never an empty inbox.
Presentation types
ActivityRow: id, at, author, avatar, label, title, href, unread.
ActivityDay: id (YYYY-MM-DD), at, rows.
ActivityPage: account, server, available, days, unread, email, emailState, emailStatus, hasMore.
The same three are declared as shapes in activity.contract.
Functions
emptyPage(server, account) is the page with available: false, email state off and status No email configured. It is also the answer when the identity has no local key.
isRead(state, id, at) follows the React Native client's rules: an event is read when at <= markAllReadAtMs (the watermark) or its id is in readEvents.
with a commentId: /c/{target.uid}/{threadRoot or commentId}, the discuss thread route
otherwise: docHref of the target's uid and path
present(snapshot, server, offset):
Sorts notifications newest first (ties by feedEventId).
Groups by local calendar day: the ISO date of eventAtMs + offset * 60000, where offset is Exact's UTC offset in minutes east of UTC (time.utcOffset in the root).
Builds each row. author is the name or Someone; title is the target name or Untitled document; avatar goes through mediaUrl at size S; label is the author plus a phrase for the reason:
| Phrase |
|---|---|
| mentioned you in |
| replied to you in |
| started a discussion in |
| started a discussion on your site in |
| updated |
| commented in |
anything else | posted in |
It then counts unread rows and derives the email state and status line from config:
| Condition |
|
|---|---|---|
| no email |
|
|
|
|
| not verified, |
|
| otherwise |
|
The returned page has available: true, account from the snapshot and hasMore from the inbox.
emailInput(input) trims and lowercases, and throws Enter a valid email address. unless the text matches something@something.something with no spaces. It is called only when the person submits, "at the user-input boundary".
Tests
activity.test.ts: the group "inbox presentation and read states" has 4 tests (day grouping with unread dots, canonical snapshots after mark-read actions, document and thread hrefs, empty inbox and fallback labels) and "email verification" has 4 (a mutation visible from its snapshot even if the next read fails, input normalisation, the off to pending to verified cycle, resending an expired link). All run against the mock notify service.
Known limits
Rows show who, what kind and which document. There is no snippet of the comment or change.
Only the latest 400 notifications are shown; hasMore produces a footnote, not paging.
The thread href uses the notification target's uid as the first route segment. Inferred: this assumes notify's commentId and threadRoot are record ids relative to that uid, which the fixture (fixture-root) matches; the real service's format was not verified here.
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime