mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-24 18:59:17 +00:00
Show the unsent symbol on the All rooms badge (#34498)
Co-authored-by: David Baker <dbkr@users.noreply.github.com>
This commit is contained in:
@@ -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("@");
|
||||
});
|
||||
});
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user