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

Commit fdcc8bb

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

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/Unread.ts

+3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ export function doesRoomHaveUnreadMessages(room: Room, includeThreads: boolean):
7474
}
7575

7676
function doesTimelineHaveUnreadMessages(room: Room, timeline: Array<MatrixEvent>): boolean {
77+
// The room is a space, let's ignore it
78+
if (room.isSpaceRoom()) return false;
79+
7780
const myUserId = room.client.getSafeUserId();
7881
const latestImportantEventId = findLatestImportantEvent(room.client, timeline)?.getId();
7982
if (latestImportantEventId) {

src/components/views/settings/Notifications.tsx

+2-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.
@@ -739,7 +740,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
739740
category === RuleClass.VectorOther &&
740741
MatrixClientPeg.safeGet()
741742
.getRooms()
742-
.some((r) => r.getUnreadNotificationCount() > 0)
743+
.some((r) => doesRoomHaveUnreadMessages(r, true))
743744
) {
744745
clearNotifsButton = (
745746
<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)