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

Commit

Permalink
Fix Mark all as read in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Feb 1, 2024
1 parent 01f0c66 commit e00856d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/components/views/settings/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -132,6 +133,7 @@ interface IState {
desktopNotifications: boolean;
desktopShowBody: boolean;
audioNotifications: boolean;
msc3946ProcessDynamicPredecessor: boolean;

clearingNotifications: boolean;

Expand Down Expand Up @@ -211,6 +213,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
desktopNotifications: SettingsStore.getValue("notificationsEnabled"),
desktopShowBody: SettingsStore.getValue("notificationBodyEnabled"),
audioNotifications: SettingsStore.getValue("audioNotificationsEnabled"),
msc3946ProcessDynamicPredecessor: SettingsStore.getValue("feature_dynamic_room_predecessors"),
clearingNotifications: false,
ruleIdsWithError: {},
};
Expand All @@ -228,6 +231,9 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
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 }),
),
];
}

Expand Down Expand Up @@ -739,7 +745,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
category === RuleClass.VectorOther &&
MatrixClientPeg.safeGet()
.getRooms()
.some((r) => r.getUnreadNotificationCount() > 0)
.some((r) => !r.isSpaceRoom() && doesRoomHaveUnreadMessages(r, true))
) {
clearNotifsButton = (
<AccessibleButton
Expand Down
3 changes: 2 additions & 1 deletion src/utils/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { IndicatorIcon } from "@vector-im/compound-web";

import SettingsStore from "../settings/SettingsStore";
import { NotificationLevel } from "../stores/notifications/NotificationLevel";
import { doesRoomHaveUnreadMessages } from "../Unread";

export const deviceNotificationSettingsKeys = [
"notificationsEnabled",
Expand Down Expand Up @@ -105,7 +106,7 @@ export async function clearRoomNotification(room: Room, client: MatrixClient): P
*/
export function clearAllNotifications(client: MatrixClient): Promise<Array<{} | undefined>> {
const receiptPromises = client.getRooms().reduce((promises: Array<Promise<{} | undefined>>, room: Room) => {
if (room.getUnreadNotificationCount() > 0) {
if (doesRoomHaveUnreadMessages(room, true)) {
const promise = clearRoomNotification(room, client);
promises.push(promise);
}
Expand Down

0 comments on commit e00856d

Please sign in to comment.