A user's settings follow their account from browser to browser, and the server reads some of them itself (a digest is drawn in its reader's style). This module types them for GET and PATCH /api/me/settings; the client keeps them with its session.

Functions

Interfaces

I
UserSettings

Returned by GET /api/me/settings, and by a PATCH once applied. The client's useSettings reads it from the session.

Type Aliases

T
DigestCadence = DIGEST_CADENCES[number]

One of the DIGEST_CADENCES. An unsubscribe link names one, which turns off its setting alone.

T
UpdateSettingsRequest = Partial<UserSettings>

Sent to PATCH /api/me/settings with the settings to change; the others keep their value.

Variables

v
DEFAULT_SETTINGS: UserSettings

The settings of a user who never changed any. Digests are on by default.

v
DIGEST_CADENCES: "weekly" | "monthly"[]

Lists how often a digest can come: weekly, or monthly as a recap.

v
DIGEST_SETTING: Record<DigestCadence, "digestWeekly" | "digestMonthly">

Names the setting that switches each cadence of digest.

v
PERIOD_MS: Record<DigestCadence, number>

How long each cadence's period lasts, rolling: a digest covers the one just ended, and the /community page the one ending now.