1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-30 02:21:17 +03:00

Don't reference the notification levels by colour (#12138)

* Don't reference the notification levels by colour

We're about to change what colours they are so either we'd have to rename
a bunch of constants. We may as well make things not reference what colour
anything is in the actual UI. Hopefully these constants are clear enough.

 * Rename NotificationColor -> NotificationLevel
 * Red -> Highlight
 * Grey -> Notification
 * Bold -> Activity
 * Anywhere else that calls it 'color' -> 'level'

Also fixes some weird mixes of US & UK English.

It turns out this is referenced in... quite a lot of places, so this is
quite a large PR. It can't really be much smaller, sorry.

* One test rename & some hiding due to ts-ignore

* More hiding behind ts-ignore

* Damn you, @ts-ignore...

* Fix test CSS values

* Missed some colour -> level

Co-authored-by: Florian Duros <florianduros@element.io>

* Change other instances of variables renamed in suggestion

* Update new test for renames

---------

Co-authored-by: Florian Duros <florianduros@element.io>
This commit is contained in:
David Baker
2024-01-15 15:25:48 +00:00
committed by GitHub
parent 97339ee2f6
commit 9254e9562e
42 changed files with 268 additions and 265 deletions

View File

@ -34,7 +34,7 @@ import {
getUnreadNotificationCount,
determineUnreadState,
} from "../src/RoomNotifs";
import { NotificationColor } from "../src/stores/notifications/NotificationColor";
import { NotificationLevel } from "../src/stores/notifications/NotificationLevel";
import SettingsStore from "../src/settings/SettingsStore";
import { MatrixClientPeg } from "../src/MatrixClientPeg";
@ -252,10 +252,10 @@ describe("RoomNotifs test", () => {
});
it("shows nothing by default", async () => {
const { color, symbol, count } = determineUnreadState(room);
const { level, symbol, count } = determineUnreadState(room);
expect(symbol).toBe(null);
expect(color).toBe(NotificationColor.None);
expect(level).toBe(NotificationLevel.None);
expect(count).toBe(0);
});
@ -269,20 +269,20 @@ describe("RoomNotifs test", () => {
event.status = EventStatus.NOT_SENT;
room.addPendingEvent(event, "txn");
const { color, symbol, count } = determineUnreadState(room);
const { level, symbol, count } = determineUnreadState(room);
expect(symbol).toBe("!");
expect(color).toBe(NotificationColor.Unsent);
expect(level).toBe(NotificationLevel.Unsent);
expect(count).toBeGreaterThan(0);
});
it("indicates the user has been invited to a channel", async () => {
room.updateMyMembership("invite");
const { color, symbol, count } = determineUnreadState(room);
const { level, symbol, count } = determineUnreadState(room);
expect(symbol).toBe("!");
expect(color).toBe(NotificationColor.Red);
expect(level).toBe(NotificationLevel.Highlight);
expect(count).toBeGreaterThan(0);
});
@ -294,10 +294,10 @@ describe("RoomNotifs test", () => {
membership: "knock",
});
jest.spyOn(room, "getMember").mockReturnValue(roomMember);
const { color, symbol, count } = determineUnreadState(room);
const { level, symbol, count } = determineUnreadState(room);
expect(symbol).toBe("!");
expect(color).toBe(NotificationColor.Red);
expect(level).toBe(NotificationLevel.Highlight);
expect(count).toBeGreaterThan(0);
});
@ -306,27 +306,27 @@ describe("RoomNotifs test", () => {
room.setUnreadNotificationCount(NotificationCountType.Total, 99);
muteRoom(room);
const { color, count } = determineUnreadState(room);
const { level, count } = determineUnreadState(room);
expect(color).toBe(NotificationColor.None);
expect(level).toBe(NotificationLevel.None);
expect(count).toBe(0);
});
it("uses the correct number of unreads", async () => {
room.setUnreadNotificationCount(NotificationCountType.Total, 999);
const { color, count } = determineUnreadState(room);
const { level, count } = determineUnreadState(room);
expect(color).toBe(NotificationColor.Grey);
expect(level).toBe(NotificationLevel.Notification);
expect(count).toBe(999);
});
it("uses the correct number of highlights", async () => {
room.setUnreadNotificationCount(NotificationCountType.Highlight, 888);
const { color, count } = determineUnreadState(room);
const { level, count } = determineUnreadState(room);
expect(color).toBe(NotificationColor.Red);
expect(level).toBe(NotificationLevel.Highlight);
expect(count).toBe(888);
});
});