From e00856deb8af8cf30e715e14bd375cf451fb5e16 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/components/views/settings/Notifications.tsx | 8 +++++++- src/utils/notifications.ts | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/views/settings/Notifications.tsx b/src/components/views/settings/Notifications.tsx index a800e1db8699..6782c34e509b 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. @@ -132,6 +133,7 @@ interface IState { desktopNotifications: boolean; desktopShowBody: boolean; audioNotifications: boolean; + msc3946ProcessDynamicPredecessor: boolean; clearingNotifications: boolean; @@ -211,6 +213,7 @@ export default class Notifications extends React.PureComponent { desktopNotifications: SettingsStore.getValue("notificationsEnabled"), desktopShowBody: SettingsStore.getValue("notificationBodyEnabled"), audioNotifications: SettingsStore.getValue("audioNotificationsEnabled"), + msc3946ProcessDynamicPredecessor: SettingsStore.getValue("feature_dynamic_room_predecessors"), clearingNotifications: false, ruleIdsWithError: {}, }; @@ -228,6 +231,9 @@ export default class Notifications extends React.PureComponent { SettingsStore.watchSetting("audioNotificationsEnabled", null, (...[, , , , value]) => this.setState({ audioNotifications: value as boolean }), ), + SettingsStore.watchSetting("feature_dynamic_room_predecessors", null, (...[, , , , value]) => + this.setState({ msc3946ProcessDynamicPredecessor: value as boolean }), + ), ]; } @@ -739,7 +745,7 @@ export default class Notifications extends React.PureComponent { category === RuleClass.VectorOther && MatrixClientPeg.safeGet() .getRooms() - .some((r) => r.getUnreadNotificationCount() > 0) + .some((r) => !r.isSpaceRoom() && 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); }