aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/room.cpp13
-rw-r--r--lib/room.h2
2 files changed, 9 insertions, 6 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index 10e827d7..13589ee9 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -121,7 +121,7 @@ public:
int notificationCount = 0;
members_map_t membersMap;
QList<User*> usersTyping;
- QMultiHash<QString, User*> eventIdReadUsers;
+ QHash<QString, QSet<User*>> eventIdReadUsers;
QList<User*> usersInvited;
QList<User*> membersLeft;
int unreadMessages = 0;
@@ -627,8 +627,11 @@ Room::Changes Room::Private::setLastReadEvent(User* u, QString eventId)
auto& storedId = lastReadEventIds[u];
if (storedId == eventId)
return Change::NoChange;
- eventIdReadUsers.remove(storedId, u);
- eventIdReadUsers.insert(eventId, u);
+ auto& oldEventReadUsers = eventIdReadUsers[storedId];
+ oldEventReadUsers.remove(u);
+ if (oldEventReadUsers.isEmpty())
+ eventIdReadUsers.remove(storedId);
+ eventIdReadUsers[eventId].insert(u);
swap(storedId, eventId);
emit q->lastReadEventChanged(u);
emit q->readMarkerForUserMoved(u, eventId, storedId);
@@ -965,9 +968,9 @@ QString Room::readMarkerEventId() const
return d->lastReadEventIds.value(localUser());
}
-QList<User*> Room::usersAtEventId(const QString& eventId)
+QSet<User*> Room::usersAtEventId(const QString& eventId)
{
- return d->eventIdReadUsers.values(eventId);
+ return d->eventIdReadUsers.value(eventId);
}
int Room::notificationCount() const { return d->notificationCount; }
diff --git a/lib/room.h b/lib/room.h
index cdbfe58f..fa7b6e6d 100644
--- a/lib/room.h
+++ b/lib/room.h
@@ -364,7 +364,7 @@ public:
rev_iter_t readMarker(const User* user) const;
rev_iter_t readMarker() const;
QString readMarkerEventId() const;
- QList<User*> usersAtEventId(const QString& eventId);
+ QSet<User*> usersAtEventId(const QString& eventId);
/**
* \brief Mark the event with uptoEventId as read
*