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] {
refresh(room, {DisplayNameRole});
});
connect(room, &Room::unreadStatsChanged, this, [this, room] {
refresh(room, {ContextNotificationCountRole, HasHighlightNotificationsRole, NotificationCountRole});
connect(room, &Room::changed, this, [this, room](Room::Changes changes) {
if (changes & (Room::Change::UnreadStats | Room::Change::Highlights)) {
refresh(room, {ContextNotificationCountRole, HasHighlightNotificationsRole, NotificationCountRole});
}
});
connect(room, &Room::notificationCountChanged, this, [this, room] {
refresh(room);

View File

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

View File

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

View File

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