From d4cb9619ea82ebc4471c2d1a9546d1ec49f71b7a Mon Sep 17 00:00:00 2001 From: hayyaksi <193020925+hayaksi1@users.noreply.github.com> Date: Fri, 14 Aug 2026 10:41:06 +0000 Subject: [PATCH] Show the unsent symbol on the All rooms badge (#34498) Co-authored-by: David Baker --- .../SummarizedNotificationState.test.ts | 41 +++++++++++++++++++ .../SummarizedNotificationState.ts | 8 ++++ 2 files changed, 49 insertions(+) create mode 100644 apps/web/src/stores/notifications/SummarizedNotificationState.test.ts diff --git a/apps/web/src/stores/notifications/SummarizedNotificationState.test.ts b/apps/web/src/stores/notifications/SummarizedNotificationState.test.ts new file mode 100644 index 0000000000..d9854af661 --- /dev/null +++ b/apps/web/src/stores/notifications/SummarizedNotificationState.test.ts @@ -0,0 +1,41 @@ +/* +Copyright 2026 hayaksi1 + +SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial +Please see LICENSE files in the repository root for full details. +*/ + +// @vitest-environment happy-dom + +import { describe, it, expect } from "vitest"; + +import { SummarizedNotificationState } from "./SummarizedNotificationState"; +import { StaticNotificationState } from "./StaticNotificationState"; +import { NotificationLevel } from "./NotificationLevel"; + +describe("SummarizedNotificationState", () => { + it("reports the unsent symbol when one of the summarized states failed to send", () => { + const state = new SummarizedNotificationState(); + state.add(StaticNotificationState.forCount(12, NotificationLevel.Notification)); + state.add(new StaticNotificationState("!", 1, NotificationLevel.Unsent)); + + expect(state.level).toBe(NotificationLevel.Unsent); + expect(state.symbol).toBe("!"); + }); + + it("keeps reporting the count when nothing failed to send", () => { + const state = new SummarizedNotificationState(); + state.add(StaticNotificationState.forCount(12, NotificationLevel.Notification)); + + expect(state.level).toBe(NotificationLevel.Notification); + expect(state.symbol).toBeNull(); + expect(state.count).toBe(12); + }); + + it("still adopts an explicit symbol below the unsent level", () => { + const state = new SummarizedNotificationState(); + state.add(StaticNotificationState.forSymbol("@", NotificationLevel.Highlight), true); + + expect(state.symbol).toBe("@"); + }); +}); diff --git a/apps/web/src/stores/notifications/SummarizedNotificationState.ts b/apps/web/src/stores/notifications/SummarizedNotificationState.ts index 0d223834e6..70a0b289cf 100644 --- a/apps/web/src/stores/notifications/SummarizedNotificationState.ts +++ b/apps/web/src/stores/notifications/SummarizedNotificationState.ts @@ -29,6 +29,14 @@ export class SummarizedNotificationState extends NotificationState { return this.totalStatesWithUnread; } + /** + * Matches {@link SpaceNotificationState.symbol}: a failure to send is reported as "!" rather + * than as a count, so the summarized badge does not present it as a notification count. + */ + public get symbol(): string | null { + return this._level === NotificationLevel.Unsent ? "!" : this._symbol; + } + /** * Append a notification state to this snapshot, taking the loudest NotificationColor * of the two. By default this will not adopt the symbol of the other notification