Room list: increase startup performance when rooms have notifications (#34358)
* Throttle section header update when listening to room notifications * Update room list section header tests
This commit is contained in:
@@ -250,11 +250,16 @@ describe("RoomListSectionHeaderViewModel", () => {
|
||||
let notificationState: RoomNotificationState;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers();
|
||||
room = mkRoom(matrixClient, "!room:server");
|
||||
notificationState = new RoomNotificationState(room, false);
|
||||
jest.spyOn(RoomNotificationStateStore.instance, "getRoomState").mockReturnValue(notificationState);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
it("should set isUnread to false when no rooms have notifications", () => {
|
||||
const vm = new RoomListSectionHeaderViewModel({
|
||||
tag: "m.favourite",
|
||||
@@ -327,6 +332,7 @@ describe("RoomListSectionHeaderViewModel", () => {
|
||||
jest.spyOn(notificationState, "hasAnyNotificationOrActivity", "get").mockReturnValue(true);
|
||||
notificationState.emit(NotificationStateEvents.Update);
|
||||
|
||||
jest.advanceTimersByTime(200);
|
||||
expect(vm.getSnapshot().isUnread).toBe(true);
|
||||
});
|
||||
|
||||
@@ -549,6 +555,7 @@ describe("RoomListSectionHeaderViewModel", () => {
|
||||
jest.spyOn(notificationState, "isMention", "get").mockReturnValue(true);
|
||||
notificationState.emit(NotificationStateEvents.Update);
|
||||
|
||||
jest.advanceTimersByTime(200);
|
||||
expect(vm.getSnapshot().notification?.isMention).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user