Let sleep tracking be switched off

Settings gets a Track sleep switch, stored on the synced profile as
sleepOff (negative, so a profile from before it, or an old client that
doesn't send it, means tracking). Off hides everything marked
data-sleep-only (the sleep log buttons, the Sleep tab, the Sleep/Awake
tiles, Last sleep and the Sleep & wake list) plus the bar timer. The
sleep state also reads as unknown, so a leftover sleep-start can't dim
the log buttons or run a sleep rail through every day's history.

The reminder scheduler treats the state as unknown too. Otherwise a
leftover sleep-start would mute every other rule for good, or a leftover
sleep-end would fire the sleep rule every interval. Nothing logged is
deleted.
This commit is contained in:
Alexander Heldt committed 2026-11-12 10:27:03 +00:00
1 parent f98137097c
commit a01d74e9d5
7 files changed
+176 -32

No files matched your search

+17
View File
@@ -136,6 +136,18 @@ of them, because logging has to be one tap from wherever you are.
why tabbed apps get a reputation for trapping you: flick between tabs fifteen
times and it takes fifteen presses to escape. Two presses, always, from
anywhere.
- **Sleep tracking can be switched off** (Settings → *Track sleep*) by an
account that has stopped logging it. Everything that asks for sleep or shows
it carries `data-sleep-only` and is hidden — the log buttons, the Sleep tab,
the overview's Sleep/Awake tiles and Last sleep row, the Sleep & wake list —
along with the bar timer, and the sleep state reads as unknown, so a
`sleep-start` left over from before can't dim the log buttons or run a sleep
rail through every day's history. Nothing is deleted: sleep events stay in
History, and switching it back on brings the rest back. It is part of the
synced profile rather than a device preference, because the server's
reminders need it and it decides what a guest is asked to log. The field is
the negative `sleepOff`, so a profile from before it existed, or a client too
old to send it, means tracking.
## Layout
@@ -347,6 +359,11 @@ Opt-in push notifications for the two things that are easy to lose track of:
night — and means an overdue rule fires promptly on waking instead. The server
derives sleep state exactly the way `currentSleepState()` does in `app.js`,
tie-break included, so both sides always agree.
- **Unless sleep isn't tracked.** With *Track sleep* off, the sleep state is
unknown whatever boundaries are left in the log: the sleep rule never fires
and the others are never suppressed. Reading the last boundary anyway would
hold the puppy asleep — and every other rule silent — from the day tracking
stopped.
- **One notification per rule.** Every push carries a `tag`, so a repeat replaces
the previous notification instead of stacking another one on the lock screen.
- **Late syncs cancel a reminder retroactively.** Rules measure from the event's