Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit e00856d

Browse files
committed
Fix Mark all as read in settings
1 parent 01f0c66 commit e00856d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/components/views/settings/Notifications.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import {
5757
import { Caption } from "../typography/Caption";
5858
import { SettingsSubsectionHeading } from "./shared/SettingsSubsectionHeading";
5959
import SettingsSubsection from "./shared/SettingsSubsection";
60+
import { doesRoomHaveUnreadMessages } from "../../../Unread";
6061

6162
// TODO: this "view" component still has far too much application logic in it,
6263
// which should be factored out to other files.
@@ -132,6 +133,7 @@ interface IState {
132133
desktopNotifications: boolean;
133134
desktopShowBody: boolean;
134135
audioNotifications: boolean;
136+
msc3946ProcessDynamicPredecessor: boolean;
135137

136138
clearingNotifications: boolean;
137139

@@ -211,6 +213,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
211213
desktopNotifications: SettingsStore.getValue("notificationsEnabled"),
212214
desktopShowBody: SettingsStore.getValue("notificationBodyEnabled"),
213215
audioNotifications: SettingsStore.getValue("audioNotificationsEnabled"),
216+
msc3946ProcessDynamicPredecessor: SettingsStore.getValue("feature_dynamic_room_predecessors"),
214217
clearingNotifications: false,
215218
ruleIdsWithError: {},
216219
};
@@ -228,6 +231,9 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
228231
SettingsStore.watchSetting("audioNotificationsEnabled", null, (...[, , , , value]) =>
229232
this.setState({ audioNotifications: value as boolean }),
230233
),
234+
SettingsStore.watchSetting("feature_dynamic_room_predecessors", null, (...[, , , , value]) =>
235+
this.setState({ msc3946ProcessDynamicPredecessor: value as boolean }),
236+
),
231237
];
232238
}
233239

@@ -739,7 +745,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
739745
category === RuleClass.VectorOther &&
740746
MatrixClientPeg.safeGet()
741747
.getRooms()
742-
.some((r) => r.getUnreadNotificationCount() > 0)
748+
.some((r) => !r.isSpaceRoom() && doesRoomHaveUnreadMessages(r, true))
743749
) {
744750
clearNotifsButton = (
745751
<AccessibleButton

src/utils/notifications.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { IndicatorIcon } from "@vector-im/compound-web";
2626

2727
import SettingsStore from "../settings/SettingsStore";
2828
import { NotificationLevel } from "../stores/notifications/NotificationLevel";
29+
import { doesRoomHaveUnreadMessages } from "../Unread";
2930

3031
export const deviceNotificationSettingsKeys = [
3132
"notificationsEnabled",
@@ -105,7 +106,7 @@ export async function clearRoomNotification(room: Room, client: MatrixClient): P
105106
*/
106107
export function clearAllNotifications(client: MatrixClient): Promise<Array<{} | undefined>> {
107108
const receiptPromises = client.getRooms().reduce((promises: Array<Promise<{} | undefined>>, room: Room) => {
108-
if (room.getUnreadNotificationCount() > 0) {
109+
if (doesRoomHaveUnreadMessages(room, true)) {
109110
const promise = clearRoomNotification(room, client);
110111
promises.push(promise);
111112
}

0 commit comments

Comments
 (0)