Fix favicon/title badge count
This was using a separate function (in MatrixChat) that didn't take into account whether we were supposed to be hiding the badge for rooms so would include notifs that were hidden everywhere else. Also make it a function & put it in RoomNotifs with all its friends. Fixes https://github.com/vector-im/riot-web/issues/3060
This commit is contained in:
parent
9591e6b0d3
commit
edd43a2706
2 changed files with 23 additions and 13 deletions
|
@ -35,6 +35,27 @@ function _shouldShowMentionBadge(roomNotifState) {
|
|||
return roomNotifState !== MUTE;
|
||||
}
|
||||
|
||||
export function countRoomsWithNotif(rooms) {
|
||||
return rooms.reduce((result, room, index) => {
|
||||
const roomNotifState = getRoomNotifsState(room.roomId);
|
||||
const highlight = room.getUnreadNotificationCount('highlight') > 0;
|
||||
const notificationCount = room.getUnreadNotificationCount();
|
||||
|
||||
const notifBadges = notificationCount > 0 && _shouldShowNotifBadge(roomNotifState);
|
||||
const mentionBadges = highlight && _shouldShowMentionBadge(roomNotifState);
|
||||
const isInvite = room.hasMembershipState(MatrixClientPeg.get().credentials.userId, 'invite');
|
||||
const badges = notifBadges || mentionBadges || isInvite;
|
||||
|
||||
if (badges) {
|
||||
result.count++;
|
||||
if (highlight) {
|
||||
result.highlight = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}, {count: 0, highlight: false});
|
||||
}
|
||||
|
||||
export function aggregateNotificationCount(rooms) {
|
||||
return rooms.reduce((result, room, index) => {
|
||||
const roomNotifState = getRoomNotifsState(room.roomId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue