From 52beda703bd683944ce569c50bccde7ba9e5a0ac Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Mon, 19 Jul 2021 22:05:52 +0200 Subject: addHistoricalMessageEvents(): restore force-recount logic Pre-e12d7ba2, addHistoricalMessageEvents() triggered recounting and emitting unreadMessagesChanged() even if the number remained the same. This logic has been lost when refactoring the code; now it's back there again. --- lib/room.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/room.cpp b/lib/room.cpp index c9a1856f..49ce4c87 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -315,7 +315,7 @@ public: QString newEvtId = {}); Changes setFullyReadMarker(const QString &eventId); Changes updateUnreadCount(const rev_iter_t& from, const rev_iter_t& to); - Changes recalculateUnreadCount(); + Changes recalculateUnreadCount(bool force = false); void markMessagesAsRead(const rev_iter_t &upToMarker); void getAllMembers(); @@ -701,10 +701,10 @@ Room::Changes Room::Private::updateUnreadCount(const rev_iter_t& from, // unreadMessages to get an exact number instead of an estimation // (see https://github.com/quotient-im/libQuotient/wiki/unread_count). // For the same reason (switching from the estimation to the exact - // number) this branch always returns UnreadNotifsChange, even if - // the estimation luckily matched the exact result. - recalculateUnreadCount(); - return UnreadNotifsChange; + // number) this branch always emits unreadMessagesChanged() and returns + // UnreadNotifsChange, even if the estimation luckily matched the exact + // result. + return recalculateUnreadCount(true); } // Fully read marker is somewhere beyond the most historical message from @@ -739,7 +739,7 @@ Room::Changes Room::Private::updateUnreadCount(const rev_iter_t& from, return UnreadNotifsChange; } -Room::Changes Room::Private::recalculateUnreadCount() +Room::Changes Room::Private::recalculateUnreadCount(bool force) { // Recalculate unread messages const auto oldUnreadCount = unreadMessages; @@ -756,7 +756,7 @@ Room::Changes Room::Private::recalculateUnreadCount() if (unreadMessages == 0) unreadMessages = -1; - if (unreadMessages == oldUnreadCount) + if (!force && unreadMessages == oldUnreadCount) return NoChange; if (unreadMessages == -1) -- cgit v1.2.3