diff --git a/src/libneochat/models/roomlistmodel.cpp b/src/libneochat/models/roomlistmodel.cpp index 88c0b50ce..bec0dedd8 100644 --- a/src/libneochat/models/roomlistmodel.cpp +++ b/src/libneochat/models/roomlistmodel.cpp @@ -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); diff --git a/src/libneochat/neochatconnection.cpp b/src/libneochat/neochatconnection.cpp index 66ccfecbc..23775affa 100644 --- a/src/libneochat/neochatconnection.cpp +++ b/src/libneochat/neochatconnection.cpp @@ -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) { diff --git a/src/libneochat/spacehierarchycache.cpp b/src/libneochat/spacehierarchycache.cpp index 9fe5cd248..5022f0183 100644 --- a/src/libneochat/spacehierarchycache.cpp +++ b/src/libneochat/spacehierarchycache.cpp @@ -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); diff --git a/src/rooms/models/roomtreemodel.cpp b/src/rooms/models/roomtreemodel.cpp index 105b517e5..e7a1e6551 100644 --- a/src/rooms/models/roomtreemodel.cpp +++ b/src/rooms/models/roomtreemodel.cpp @@ -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] {