Commit 3815908c8f

3815908c8ffaa23d179d01c8c6354c4e69a250e4

parent: 061bd0662c

Verified · cmc

cmc <hello@cleberg.net> · 2026-09-28 08:28 UTC

notifications list: name --all only when read items exist

Ref #265

Layout: unified · split

internal/control/notifications.go +3 −1
@@ -421,7 +421,9 @@ func runNotificationsList(c *Ctx, args []string) int {
421421 if !c.JSON && !p.active && len(ds) == 0 {
422422 msg := "nothing to list"
423423 if !all {
424 msg = "no unread notifications (--all for read ones)"
424 if read, err := c.Store.Inbox(c.User.ID, false, 1, 0); err == nil && len(read) > 0 {
425 msg = "no unread notifications (--all for read ones)"
426 }
425427 }
426428 fmt.Fprintln(c.Stderr, msg)
427429 return protocol.ExitOK
internal/control/notifications_test.go +12
@@ -270,6 +270,18 @@ func TestNotificationsSettingsShowsPush(t *testing.T) {
270270
271271func TestNotificationsListEmptyUnreadSaysHowToSeeRead(t *testing.T) {
272272 c, repo, bob := testRepoWithWatcher(t)
273 // An inbox with nothing in it at all keeps the plain message.
274 var empty bytes.Buffer
275 alice := c.User
276 c.User = store.User{ID: bob, Username: "bob"}
277 c.Stdout, c.Stderr = &bytes.Buffer{}, &empty
278 if code := runNotificationsList(c, nil); code != protocol.ExitOK {
279 t.Fatalf("exit %d: %s", code, empty.String())
280 }
281 if got := empty.String(); got != "nothing to list\n" {
282 t.Errorf("empty inbox stderr = %q", got)
283 }
284 c.User = alice
273285 // Give bob one notice (acting as alice, so bob isn't filtered out as
274286 // the actor), then mark it read as bob, so his inbox has rows but no
275287 // unread ones.