Fix notification count refresh for low-priority and mentions-only rooms

(cherry picked from commit 5f7967363f)
This commit is contained in:
Azhar Momin
2026-01-03 14:49:43 +05:30
committed by Joshua Goins
parent b3aa2abd89
commit e156d4da90
4 changed files with 30 additions and 20 deletions

View File

@@ -118,8 +118,10 @@ void RoomListModel::connectRoomSignals(NeoChatRoom *room)
connect(room, &Room::displaynameChanged, this, [this, room] { connect(room, &Room::displaynameChanged, this, [this, room] {
refresh(room, {DisplayNameRole}); refresh(room, {DisplayNameRole});
}); });
connect(room, &Room::unreadStatsChanged, this, [this, room] { connect(room, &Room::changed, this, [this, room](Room::Changes changes) {
refresh(room, {ContextNotificationCountRole, HasHighlightNotificationsRole, NotificationCountRole}); if (changes & (Room::Change::UnreadStats | Room::Change::Highlights)) {
refresh(room, {ContextNotificationCountRole, HasHighlightNotificationsRole, NotificationCountRole});
}
}); });
connect(room, &Room::notificationCountChanged, this, [this, room] { connect(room, &Room::notificationCountChanged, this, [this, room] {
refresh(room); refresh(room);

View File

@@ -75,31 +75,37 @@ void NeoChatConnection::connectSignals()
Q_EMIT directChatInvitesChanged(); Q_EMIT directChatInvitesChanged();
for (const auto &chatId : additions) { for (const auto &chatId : additions) {
if (const auto chat = room(chatId)) { if (const auto chat = room(chatId)) {
connect(chat, &Room::unreadStatsChanged, this, [this]() { connect(chat, &Room::changed, this, [this](Room::Changes changes) {
refreshBadgeNotificationCount(); if (changes & (Room::Change::UnreadStats | Room::Change::Highlights)) {
Q_EMIT directChatNotificationsChanged(); refreshBadgeNotificationCount();
Q_EMIT directChatsHaveHighlightNotificationsChanged(); Q_EMIT directChatNotificationsChanged();
Q_EMIT directChatsHaveHighlightNotificationsChanged();
}
}); });
} }
} }
for (const auto &chatId : removals) { for (const auto &chatId : removals) {
if (const auto chat = room(chatId)) { if (const auto chat = room(chatId)) {
disconnect(chat, &Room::unreadStatsChanged, this, nullptr); disconnect(chat, &Room::changed, this, nullptr);
} }
} }
}); });
connect(this, &NeoChatConnection::joinedRoom, this, [this](Room *room) { connect(this, &NeoChatConnection::joinedRoom, this, [this](Room *room) {
if (room->isDirectChat()) { if (room->isDirectChat()) {
connect(room, &Room::unreadStatsChanged, this, [this]() { connect(room, &Room::changed, this, [this](Room::Changes changes) {
Q_EMIT directChatNotificationsChanged(); if (changes & (Room::Change::UnreadStats | Room::Change::Highlights)) {
Q_EMIT directChatsHaveHighlightNotificationsChanged(); Q_EMIT directChatNotificationsChanged();
Q_EMIT directChatsHaveHighlightNotificationsChanged();
}
}); });
} }
Q_EMIT roomInvitesChanged(); Q_EMIT roomInvitesChanged();
connect(room, &Room::unreadStatsChanged, this, [this]() { connect(room, &Room::changed, this, [this](Room::Changes changes) {
refreshBadgeNotificationCount(); if (changes & (Room::Change::UnreadStats | Room::Change::Highlights)) {
Q_EMIT homeNotificationsChanged(); refreshBadgeNotificationCount();
Q_EMIT homeHaveHighlightNotificationsChanged(); Q_EMIT homeNotificationsChanged();
Q_EMIT homeHaveHighlightNotificationsChanged();
}
}); });
}); });
connect(this, &NeoChatConnection::leftRoom, this, [this](Room *room, Room *prev) { connect(this, &NeoChatConnection::leftRoom, this, [this](Room *room, Room *prev) {

View File

@@ -43,8 +43,8 @@ void SpaceHierarchyCache::cacheSpaceHierarchy()
Qt::SingleShotConnection); Qt::SingleShotConnection);
} }
connect(neoChatRoom, &NeoChatRoom::unreadStatsChanged, this, [this, neoChatRoom]() { connect(neoChatRoom, &NeoChatRoom::changed, this, [this, neoChatRoom](NeoChatRoom::Changes changes) {
if (neoChatRoom != nullptr) { if (neoChatRoom != nullptr && (changes & (NeoChatRoom::Change::UnreadStats | NeoChatRoom::Change::Highlights))) {
const auto parents = parentSpaces(neoChatRoom->id()); const auto parents = parentSpaces(neoChatRoom->id());
if (parents.count() > 0) { if (parents.count() > 0) {
Q_EMIT spaceNotifcationCountChanged(parents); Q_EMIT spaceNotifcationCountChanged(parents);

View File

@@ -170,10 +170,12 @@ void RoomTreeModel::connectRoomSignals(NeoChatRoom *room)
connect(room, &Room::displaynameChanged, this, [this, room] { connect(room, &Room::displaynameChanged, this, [this, room] {
refreshRoomRoles(room, {DisplayNameRole}); refreshRoomRoles(room, {DisplayNameRole});
}); });
connect(room, &Room::unreadStatsChanged, this, [this, room] { connect(room, &Room::changed, this, [this, room](Room::Changes changes) {
refreshRoomRoles(room, {ContextNotificationCountRole, HasHighlightNotificationsRole, NotificationCountRole}); if (changes & (Room::Change::UnreadStats | Room::Change::Highlights)) {
if (room->isServerNoticeRoom()) { refreshRoomRoles(room, {ContextNotificationCountRole, HasHighlightNotificationsRole, NotificationCountRole});
Q_EMIT invalidateSort(); if (room->isServerNoticeRoom()) {
Q_EMIT invalidateSort();
}
} }
}); });
connect(room, &Room::avatarChanged, this, [this, room] { connect(room, &Room::avatarChanged, this, [this, room] {