Activity: screens, tasks and email settings
activity.contract and the pkg:activity blocks of app.contract: the inbox and email screens, state, four tasks, actions, the mutation and its Contract tests.

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

activityEmail, activityEmailOwner, activityEmailServer

The email draft and the account and server it belongs to.

activityTick

performanceNow() at the last ask; the screen's now is time.epochAtZero + activityTick.

activityAskServer, activityAskAccount, activityAskAt

The ask stamp: written by activityAsk, 0 when not asking.

activityActive

nav.tab == "activity"

activityData

resource … = activityLoad(activityAskServer, activityAskAccount, activityAskAt > 0, time.utcOffset) with activityAskAt as shape ActivityPage else empty()

activityChanged

mutation … as shape ActivityReply refreshes activityData then activityAfterChange

activityReady

The loaded page's account and server equal the current ones.

activityDraft

The typed draft when it belongs to this account and server, else the loaded email.

activityError, activitySaveError

failure(activityData)'s message; the mutation's error, only when its page is for the current owner.

Tasks

Task

Runs when

Does

activityWake

the tab is active, keyed by server and account

after(1, activityAsk)

activityClock

the tab is active

every(60000, activityAsk)

activitySleep

the tab is not active and activityAskAt > 0

after(1, activityPark), which sets activityAskAt = 0

activityVerification

active, ready, and emailState is pending or expired

every(3000, activityPoll); the poll asks only when neither the resource nor the mutation is pending

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.

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime

Attributes
name
Activity: screens, tasks and email settings
summary
activity.contract and the pkg:activity blocks of app.contract: the inbox and email screens, state, four tasks, actions, the mutation and its Contract tests.