mirror of
https://github.com/element-hq/element-web
synced 2024-11-25 02:35:48 +03:00
Add local echo on badges in breadcrumbs
Fixes https://github.com/vector-im/riot-web/issues/9890
This commit is contained in:
parent
7a4d69f037
commit
dd42e87c3c
1 changed files with 12 additions and 3 deletions
|
@ -96,6 +96,13 @@ export default class RoomBreadcrumbs extends React.Component {
|
|||
case 'view_room':
|
||||
this._appendRoomId(payload.room_id);
|
||||
break;
|
||||
|
||||
// XXX: slight hack in order to zero the notification count when a room
|
||||
// is read. Copied from RoomTile
|
||||
case 'on_room_read':
|
||||
const room = MatrixClientPeg.get().getRoom(payload.roomId);
|
||||
this._calculateRoomBadges(room, /*zero=*/true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,7 +171,7 @@ export default class RoomBreadcrumbs extends React.Component {
|
|||
});
|
||||
}
|
||||
|
||||
_calculateBadgesForRoom(room) {
|
||||
_calculateBadgesForRoom(room, zero=false) {
|
||||
if (!room) return null;
|
||||
|
||||
// Reset the notification variables for simplicity
|
||||
|
@ -174,6 +181,8 @@ export default class RoomBreadcrumbs extends React.Component {
|
|||
showCount: false,
|
||||
};
|
||||
|
||||
if (zero) return roomModel;
|
||||
|
||||
const notifState = RoomNotifs.getRoomNotifsState(room.roomId);
|
||||
if (RoomNotifs.MENTION_BADGE_STATES.includes(notifState)) {
|
||||
const highlightNotifs = RoomNotifs.getUnreadNotificationCount(room, 'highlight');
|
||||
|
@ -195,14 +204,14 @@ export default class RoomBreadcrumbs extends React.Component {
|
|||
return roomModel;
|
||||
}
|
||||
|
||||
_calculateRoomBadges(room) {
|
||||
_calculateRoomBadges(room, zero=false) {
|
||||
if (!room) return;
|
||||
|
||||
const rooms = this.state.rooms.slice();
|
||||
const roomModel = rooms.find((r) => r.room.roomId === room.roomId);
|
||||
if (!roomModel) return; // No applicable room, so don't do math on it
|
||||
|
||||
const badges = this._calculateBadgesForRoom(room);
|
||||
const badges = this._calculateBadgesForRoom(room, zero);
|
||||
if (!badges) return; // No badges for some reason
|
||||
|
||||
Object.assign(roomModel, badges);
|
||||
|
|
Loading…
Reference in a new issue