mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-17 05:55:00 +08: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
@ -96,6 +96,13 @@ export default class RoomBreadcrumbs extends React.Component {
|
|||||||
case 'view_room':
|
case 'view_room':
|
||||||
this._appendRoomId(payload.room_id);
|
this._appendRoomId(payload.room_id);
|
||||||
break;
|
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;
|
if (!room) return null;
|
||||||
|
|
||||||
// Reset the notification variables for simplicity
|
// Reset the notification variables for simplicity
|
||||||
@ -174,6 +181,8 @@ export default class RoomBreadcrumbs extends React.Component {
|
|||||||
showCount: false,
|
showCount: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (zero) return roomModel;
|
||||||
|
|
||||||
const notifState = RoomNotifs.getRoomNotifsState(room.roomId);
|
const notifState = RoomNotifs.getRoomNotifsState(room.roomId);
|
||||||
if (RoomNotifs.MENTION_BADGE_STATES.includes(notifState)) {
|
if (RoomNotifs.MENTION_BADGE_STATES.includes(notifState)) {
|
||||||
const highlightNotifs = RoomNotifs.getUnreadNotificationCount(room, 'highlight');
|
const highlightNotifs = RoomNotifs.getUnreadNotificationCount(room, 'highlight');
|
||||||
@ -195,14 +204,14 @@ export default class RoomBreadcrumbs extends React.Component {
|
|||||||
return roomModel;
|
return roomModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
_calculateRoomBadges(room) {
|
_calculateRoomBadges(room, zero=false) {
|
||||||
if (!room) return;
|
if (!room) return;
|
||||||
|
|
||||||
const rooms = this.state.rooms.slice();
|
const rooms = this.state.rooms.slice();
|
||||||
const roomModel = rooms.find((r) => r.room.roomId === room.roomId);
|
const roomModel = rooms.find((r) => r.room.roomId === room.roomId);
|
||||||
if (!roomModel) return; // No applicable room, so don't do math on it
|
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
|
if (!badges) return; // No badges for some reason
|
||||||
|
|
||||||
Object.assign(roomModel, badges);
|
Object.assign(roomModel, badges);
|
||||||
|
Loading…
Reference in New Issue
Block a user