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

Re-use doesRoomHaveUnreadThreads for useRoomThreadNotifications #12195

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/hooks/room/useRoomThreadNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { NotificationCountType, Room, RoomEvent, ThreadEvent } from "matrix-js-s
import { useCallback, useEffect, useState } from "react";

import { NotificationLevel } from "../../stores/notifications/NotificationLevel";
import { doesRoomOrThreadHaveUnreadMessages } from "../../Unread";
import { doesRoomHaveUnreadThreads } from "../../Unread";
import { useEventEmitter } from "../useEventEmitter";

/**
Expand All @@ -40,13 +40,7 @@ export const useRoomThreadNotifications = (room: Room): NotificationLevel => {
}
// We don't have any notified messages, but we might have unread messages. Let's
// find out.
for (const thread of room!.getThreads()) {
// If the current thread has unread messages, we're done.
if (doesRoomOrThreadHaveUnreadMessages(thread)) {
setNotificationLevel(NotificationLevel.Activity);
break;
}
}
if (doesRoomHaveUnreadThreads(room)) setNotificationLevel(NotificationLevel.Activity);
}, [room]);

useEventEmitter(room, RoomEvent.UnreadNotifications, updateNotification);
Expand Down
Loading