This page covers the Contract side of the activity package: the two screens in activity.contract, and the state, tasks and actions in the pkg:activity blocks of the root contract.
Root contract declarations
The two sources these declarations call, the ask stamp and the committed snapshot are described in Activity: sources, the ask stamp and the committed snapshot.
app.contract L121-L147. Routes: the activity tab at /activity and activity-email "/activity/email" (L39-L42).
Name | Meaning |
|---|---|
| The email draft and the account and server it belongs to. |
|
|
| The ask stamp: written by |
|
|
|
|
|
|
| The loaded page's |
| The typed draft when it belongs to this account and server, else the loaded email. |
|
|
Tasks
Task | Runs when | Does |
|---|---|---|
| the tab is active, keyed by server and account |
|
| the tab is active |
|
| the tab is not active and |
|
| active, ready, and |
|
Actions
app.contract L366-L415: activityRefresh (ask again), activityMe (select the Me tab), activitySettings (seed the draft, clear the last mutation, push activity-email), activityEditEmail, activitySetEmail, activityResend, activityRemoveEmail, activityMarkAll. Each write sends activityApply(server, currentAccount, kind, value, at, time.epochAtZero + performanceNow(), time.utcOffset).
activityOpenRow(id, at, href) marks the event read, selects the Read tab and goes to the row's href. A thread href (/c/…) gets ?from=activity, which makes the thread use the configured server (Read: root contract wiring).
activityAfterChange copies the reply's email into the draft when the reply is ok and for the current owner.
Screens
ActivityScreen props: eid, title, ready, hasIdentity, page, loading, error, saving, saveError, now, offset, retry, openMe, settings, markAll, openRow. Three states:
No identity, or a ready page that is not available: EmptyState "No identity selected" with activity-open-me (activity-placeholder). EmptyState comes from exact:content.
Ready, available, no days and no errors: "Nothing yet" (activity-empty, activity-empty-refresh).
Otherwise an inset grouped list with pull to refresh: activity-error and activity-retry, activity-save-error, activity-loading, then the unread line (activity-unread-count: All caught up or N unread) with activity-mark-all, one section per day (activity-day-{YYYY-MM-DD}, titled by Exact's formatDay, for example Today and Yesterday), rows (activity-row-{id}, a brand dot activity-unread-{id}), and Showing your latest 400 notifications. when hasMore.
Header buttons, shown only with an identity: activity-settings and activity-refresh.
ActivityEmailScreen props: eid, ready, hasIdentity, page, draft, saving, error, loadError, edit, save, resend, remove, retry, openMe. It shows the status line (activity-email-status), an email input (activity-email-input), a button reading Enable or Change (activity-email-save), help and activity-email-resend while pending or expired, activity-email-off when an email is set, and errors (activity-email-error, activity-email-load-error, activity-email-retry, activity-email-me).
The view switch passes ready=activityReady, hasIdentity=(currentAccount != "") and hides save errors while a write is pending.
Contract tests
activity.test.contract has 7 tests. Each sets the server to http://127.0.0.1:4790 (the local test server), imports a throwaway key, fixes the clock with epoch, and resets the mock notify service with request POST "/activity/reset":
No identity offers Me.
Grouped days, unread dots, opening a row (marks it read and pushes the document), mark all read.
Email validation, pending, polled to verified, change, turn off.
An expired verification can be resent.
A service error retries to an empty inbox.
Switching identities scopes the inbox and the email draft.
A minute on the inbox signs one request (B7): the fixture's /activity/posts counter must be exactly 1 for the first load, exactly 1 for the following minute on the tab, 0 during a minute on another tab, and 1 after returning.
See Contract UI tests.
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime