From fdcc8bb74db70d58f80704e55f2774925d772b95 Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Thu, 1 Feb 2024 16:13:53 +0100 Subject: [PATCH] Fix `Mark all as read` in settings --- src/Unread.ts | 3 +++ src/components/views/settings/Notifications.tsx | 3 ++- src/utils/notifications.ts | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Unread.ts b/src/Unread.ts index 3a177fedaec..ee74813d20b 100644 --- a/src/Unread.ts +++ b/src/Unread.ts @@ -74,6 +74,9 @@ export function doesRoomHaveUnreadMessages(room: Room, includeThreads: boolean): } function doesTimelineHaveUnreadMessages(room: Room, timeline: Array): boolean { + // The room is a space, let's ignore it + if (room.isSpaceRoom()) return false; + const myUserId = room.client.getSafeUserId(); const latestImportantEventId = findLatestImportantEvent(room.client, timeline)?.getId(); if (latestImportantEventId) { diff --git a/src/components/views/settings/Notifications.tsx b/src/components/views/settings/Notifications.tsx index a800e1db869..ec47cff7144 100644 --- a/src/components/views/settings/Notifications.tsx +++ b/src/components/views/settings/Notifications.tsx @@ -57,6 +57,7 @@ import { import { Caption } from "../typography/Caption"; import { SettingsSubsectionHeading } from "./shared/SettingsSubsectionHeading"; import SettingsSubsection from "./shared/SettingsSubsection"; +import { doesRoomHaveUnreadMessages } from "../../../Unread"; // TODO: this "view" component still has far too much application logic in it, // which should be factored out to other files. @@ -739,7 +740,7 @@ export default class Notifications extends React.PureComponent { category === RuleClass.VectorOther && MatrixClientPeg.safeGet() .getRooms() - .some((r) => r.getUnreadNotificationCount() > 0) + .some((r) => doesRoomHaveUnreadMessages(r, true)) ) { clearNotifsButton = ( > { const receiptPromises = client.getRooms().reduce((promises: Array>, room: Room) => { - if (room.getUnreadNotificationCount() > 0) { + if (doesRoomHaveUnreadMessages(room, true)) { const promise = clearRoomNotification(room, client); promises.push(promise); }