diff --git a/src/RoomNotifs.ts b/src/RoomNotifs.ts index aa696f6e29c..1380f4abddd 100644 --- a/src/RoomNotifs.ts +++ b/src/RoomNotifs.ts @@ -81,9 +81,12 @@ export function setRoomNotifsState(client: MatrixClient, roomId: string, newStat } export function getUnreadNotificationCount(room: Room, type: NotificationCountType, threadId?: string): number { - let notificationCount = !!threadId - ? room.getThreadUnreadNotificationCount(threadId, type) - : room.getUnreadNotificationCount(type); + const countShownForRoom = (): number => + SettingsStore.getValue("threadsActivityCentre") + ? room.getRoomUnreadNotificationCount(type) + : room.getUnreadNotificationCount(type); + + let notificationCount = !!threadId ? room.getThreadUnreadNotificationCount(threadId, type) : countShownForRoom(); // Check notification counts in the old room just in case there's some lost // there. We only go one level down to avoid performance issues, and theory diff --git a/src/Unread.ts b/src/Unread.ts index 7b2da855dd7..daf6bc54551 100644 --- a/src/Unread.ts +++ b/src/Unread.ts @@ -57,7 +57,12 @@ export function doesRoomHaveUnreadMessages(room: Room): boolean { return false; } - for (const withTimeline of [room, ...room.getThreads()]) { + const toCheck: Array = [room]; + if (!SettingsStore.getValue("threadsActivityCentre")) { + toCheck.push(...room.getThreads()); + } + + for (const withTimeline of toCheck) { if (doesTimelineHaveUnreadMessages(room, withTimeline.timeline)) { // We found an unread, so the room is unread return true; diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index 202d3498c6d..84a40396faa 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -1109,6 +1109,7 @@ export const SETTINGS: { [setting: string]: ISetting } = { "threadsActivityCentre": { supportedLevels: LEVELS_ACCOUNT_SETTINGS, labsGroup: LabGroup.Threads, + controller: new ReloadOnChangeController(), displayName: _td("labs|threads_activity_centre"), default: false, isFeature: true, diff --git a/test/components/views/rooms/LegacyRoomHeader-test.tsx b/test/components/views/rooms/LegacyRoomHeader-test.tsx index ed82f74630c..7dadf14dbee 100644 --- a/test/components/views/rooms/LegacyRoomHeader-test.tsx +++ b/test/components/views/rooms/LegacyRoomHeader-test.tsx @@ -792,8 +792,11 @@ function createRoom(info: IRoomCreationInfo) { const userId = client.getUserId()!; if (info.isDm) { client.getAccountData = (eventType) => { - expect(eventType).toEqual("m.direct"); - return mkDirectEvent(roomId, userId, info.userIds); + if (eventType === "m.direct") { + return mkDirectEvent(roomId, userId, info.userIds); + } else { + return undefined; + } }; } diff --git a/test/stores/RoomNotificationStateStore-test.ts b/test/stores/RoomNotificationStateStore-test.ts index acb6a593471..46b57425d6b 100644 --- a/test/stores/RoomNotificationStateStore-test.ts +++ b/test/stores/RoomNotificationStateStore-test.ts @@ -125,6 +125,7 @@ describe("RoomNotificationStateStore", function () { ret.getPendingEvents = jest.fn().mockReturnValue([]); ret.isSpaceRoom = jest.fn().mockReturnValue(false); ret.getUnreadNotificationCount = jest.fn().mockReturnValue(numUnreads); + ret.getRoomUnreadNotificationCount = jest.fn().mockReturnValue(numUnreads); return ret; } });