Display rooms & threads as unread (bold) if threads have unread messages. (#9763)
Co-authored-by: Germain <germain@souquet.com> Co-authored-by: Germain <germains@element.io> Fixes https://github.com/vector-im/element-web/issues/23907
This commit is contained in:
parent
df03112a3b
commit
da2640b7ba
9 changed files with 521 additions and 183 deletions
|
@ -15,12 +15,13 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import { NotificationCount, NotificationCountType, Room, RoomEvent } from "matrix-js-sdk/src/models/room";
|
||||
import { Thread } from "matrix-js-sdk/src/models/thread";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
import { getUnsentMessages } from "../components/structures/RoomStatusBar";
|
||||
import { getRoomNotifsState, getUnreadNotificationCount, RoomNotifState } from "../RoomNotifs";
|
||||
import { NotificationColor } from "../stores/notifications/NotificationColor";
|
||||
import { doesRoomHaveUnreadMessages } from "../Unread";
|
||||
import { doesRoomOrThreadHaveUnreadMessages } from "../Unread";
|
||||
import { EffectiveMembership, getEffectiveMembership } from "../utils/membership";
|
||||
import { useEventEmitter } from "./useEventEmitter";
|
||||
|
||||
|
@ -75,12 +76,14 @@ export const useUnreadNotifications = (
|
|||
setColor(NotificationColor.Red);
|
||||
} else if (greyNotifs > 0) {
|
||||
setColor(NotificationColor.Grey);
|
||||
} else if (!threadId) {
|
||||
// TODO: No support for `Bold` on threads at the moment
|
||||
|
||||
} else {
|
||||
// We don't have any notified messages, but we might have unread messages. Let's
|
||||
// find out.
|
||||
const hasUnread = doesRoomHaveUnreadMessages(room);
|
||||
let roomOrThread: Room | Thread = room;
|
||||
if (threadId) {
|
||||
roomOrThread = room.getThread(threadId)!;
|
||||
}
|
||||
const hasUnread = doesRoomOrThreadHaveUnreadMessages(roomOrThread);
|
||||
setColor(hasUnread ? NotificationColor.Bold : NotificationColor.None);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue