aboutsummaryrefslogtreecommitdiff
path: root/lib/room.cpp
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-07-19 22:05:52 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-07-19 22:05:52 +0200
commit52beda703bd683944ce569c50bccde7ba9e5a0ac (patch)
tree15b6bf1d61c1d48198fa04436d373666ea58d63a /lib/room.cpp
parent2f0ea91020d47cf1c3ac2bf6b0c53aa9afc6ddeb (diff)
downloadlibquotient-52beda703bd683944ce569c50bccde7ba9e5a0ac.tar.gz
libquotient-52beda703bd683944ce569c50bccde7ba9e5a0ac.zip
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.
Diffstat (limited to 'lib/room.cpp')
-rw-r--r--lib/room.cpp14
1 files 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)