diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-12-09 11:52:26 +0300 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-03-25 22:35:23 +0100 |
commit | fe1a7c61a81ff4820645ecafccd693ea0a887d36 (patch) | |
tree | e1d731f3b7beb7892cbd8fb63c2f33bf80547b3e | |
parent | 27a2f59722b6e6642dae05cd4f04f5f40304eeb1 (diff) | |
download | libquotient-fe1a7c61a81ff4820645ecafccd693ea0a887d36.tar.gz libquotient-fe1a7c61a81ff4820645ecafccd693ea0a887d36.zip |
Initialise read marker if none is found in the whole timeline
Backport of a fix to #361.
-rw-r--r-- | lib/room.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index 43abc21d..022a3bed 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -183,6 +183,7 @@ class Room::Private rev_iter_t timelineBase() const { return q->findInTimeline(-1); } void getPreviousContent(int limit = 10); + bool allHistoryLoaded() const; template <typename EventT> const EventT* getCurrentState(const QString& stateKey = {}) const @@ -370,6 +371,11 @@ const Room::PendingEvents& Room::pendingEvents() const return d->unsyncedEvents; } +bool Room::Private::allHistoryLoaded() const +{ + return !timeline.empty() && is<RoomCreateEvent>(*timeline.front()); +} + QString Room::name() const { return d->getCurrentState<RoomNameEvent>()->name(); @@ -503,7 +509,9 @@ void Room::Private::updateUnreadCount(rev_iter_t from, rev_iter_t to) // that has just arrived. In this case we should recalculate // unreadMessages and might need to promote the read marker further // over local-origin messages. - const auto readMarker = q->readMarker(); + auto readMarker = q->readMarker(); + if (readMarker == timeline.crend() && allHistoryLoaded()) + --readMarker; // Read marker not found in the timeline, initialise it if (readMarker >= from && readMarker < to) { promoteReadMarker(q->localUser(), readMarker, true); |