Calendar: in-app reminders — the seam's one standing check, a test that each occurrence is new to Home, a shorter Settings hint
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed,
+35
−6
internal/calendar/inapp_reminders_test.go+31 −0internal/calendar/reminder_seam.go+3 −5internal/calendar/templates/settings.html+1 −1
CI passed — run details
Intent
diff --git a/internal/calendar/inapp_reminders_test.go b/internal/calendar/inapp_reminders_test.go| index aebd7d0..56ad499 100644 |
| --- a/internal/calendar/inapp_reminders_test.go |
| +++ b/internal/calendar/inapp_reminders_test.go |
| @@ -201,3 +201,34 @@ func TestNoticeWhenIsPastTenseAndAllDayIsADate(t *testing.T) { |
| t.Fatalf("an all-day occurrence = %q", got) |
| } |
| } |
| + |
| +// Home's pull sees a newer occurrence of the same rule as a new item: the |
| +// notice row is replaced, unread again, under a new ID. |
| +func TestTheSeamNamesEachOccurrenceAfresh(t *testing.T) { |
| + w := newPlainWorld(t) |
| + w.app.db.G.Model(&Person{}).Where("id = ?", w.person.ID).Update("reminder_channel", ChannelInApp) |
| + start, end := soon(5) |
| + if rec := w.do("POST", "/events", url.Values{"calendar_id": {itoa(w.calendar)}, "title": {"Every day"}, "start": {start}, "end": {end}, "tz": {"UTC"}, "kind": {"meeting"}, "status": {"confirmed"}, "repeat": {"daily"}}); rec.Code != http.StatusSeeOther { |
| + t.Fatalf("create = %d", rec.Code) |
| + } |
| + read := func() NoticeSummary { |
| + t.Helper() |
| + sum, err := w.app.reminderNotices(context.Background(), w.person.ID, "", time.Now()) |
| + if err != nil || sum.Unread != 1 || len(sum.Items) != 1 { |
| + t.Fatalf("the seam = %+v %v", sum, err) |
| + } |
| + return sum |
| + } |
| + if _, _, err := w.app.h.drain(context.Background(), time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + today := read() |
| + mustRedirect(t, "dismiss", w.do("POST", "/reminders/dismiss", url.Values{})) |
| + if _, _, err := w.app.h.drain(context.Background(), time.Now().Add(24*time.Hour)); err != nil { |
| + t.Fatal(err) |
| + } |
| + tomorrow := read() |
| + if tomorrow.Items[0].ID == today.Items[0].ID || w.notices() != 1 { |
| + t.Fatalf("the next occurrence = %q after %q (%d rows), want a new ID on the same row", tomorrow.Items[0].ID, today.Items[0].ID, w.notices()) |
| + } |
| +} |
diff --git a/internal/calendar/reminder_seam.go b/internal/calendar/reminder_seam.go| index fec3fb1..c92389a 100644 |
| --- a/internal/calendar/reminder_seam.go |
| +++ b/internal/calendar/reminder_seam.go |
| @@ -49,17 +49,15 @@ type NoticeSummary struct { |
| // Home subject. In team mode it reads on the subject's roster standing, |
| // never anything stored: Unknown is dashboard.ErrUnavailable (never a |
| // short count, to a reader on another origin who cannot see a partial |
| -// notice), asked after reading too because a lease can lapse during it; |
| -// NotMember reaches nothing and so counts nothing. |
| +// notice), asked after reading, as dashboardEvents asks, because a lease |
| +// can lapse during it (Unknown before reading reads nothing, so the one |
| +// check answers both); NotMember reaches nothing and so counts nothing. |
| func (a *App) reminderNotices(ctx context.Context, id int64, subject string, _ time.Time) (NoticeSummary, error) { |
| var standing *teammode.Access |
| if a.team != nil { |
| standing = a.team.Access(ctx, subject) |
| ctx = teammode.WithAccess(ctx, standing) |
| } |
| - if standing != nil && standing.Partial() { |
| - return NoticeSummary{}, dashboard.ErrUnavailable |
| - } |
| n, err := a.store.UnreadNoticeCount(ctx, id) |
| if err != nil { |
| return NoticeSummary{}, err |
diff --git a/internal/calendar/templates/settings.html b/internal/calendar/templates/settings.html| index 3a4b4a7..43fd8f8 100644 |
| --- a/internal/calendar/templates/settings.html |
| +++ b/internal/calendar/templates/settings.html |
| @@ -58,7 +58,7 @@ |
| {{if not .Data.NoAddress}}{{template "field-select" dict |
| "ID" "reminder_channel" "Name" "reminder_channel" "Label" "How to remind me" |
| - "Hint" "In Calendar puts a reminder under Reminders at the top of every page until you dismiss it; nothing is sent. This applies to reminders you add from now on." |
| + "Hint" "In Calendar lists a reminder under Reminders until you dismiss it, and sends nothing. For reminders you add from now on." |
| "Options" (list |
| (dict "Value" "email" "Label" "By email" "Selected" (eq .Data.Channel "email")) |
| (dict "Value" "inapp" "Label" "In Calendar" "Selected" (eq .Data.Channel "inapp")) |