aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlack Hat <bhat@encom.eu.org>2018-08-29 19:54:17 +0800
committerBlack Hat <bhat@encom.eu.org>2018-08-29 19:54:17 +0800
commitbc83e269b8f64f5d0e712bf245d05925573e84d9 (patch)
tree66b18b004f16a2e0df1219809c8ac990de838671
parentd9ff200ff62fb7f5b6b51082dc3979d5454a1bec (diff)
downloadlibquotient-bc83e269b8f64f5d0e712bf245d05925573e84d9.tar.gz
libquotient-bc83e269b8f64f5d0e712bf245d05925573e84d9.zip
Use local QHash.
-rw-r--r--lib/room.cpp8
-rw-r--r--lib/room.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index 07c39498..bb15760a 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -103,6 +103,7 @@ class Room::Private
int notificationCount = 0;
members_map_t membersMap;
QList<User*> usersTyping;
+ QHash<QString, QList<User*>> eventIdReadUsers;
QList<User*> membersLeft;
int unreadMessages = 0;
bool displayed = false;
@@ -376,6 +377,8 @@ void Room::Private::setLastReadEvent(User* u, QString eventId)
auto& storedId = lastReadEventIds[u];
if (storedId == eventId)
return;
+ eventIdReadUsers[storedId].removeOne(u);
+ eventIdReadUsers[eventId].append(u);
swap(storedId, eventId);
emit q->lastReadEventChanged(u);
if (isLocalUser(u))
@@ -636,6 +639,11 @@ QString Room::readMarkerEventId() const
return d->lastReadEventIds.value(localUser());
}
+QList<User*> Room::usersAtEventId(const QString& eventId) {
+ if (!d->eventIdReadUsers.contains(eventId)) return QList<User*>();
+ return d->eventIdReadUsers[eventId];
+}
+
int Room::notificationCount() const
{
return d->notificationCount;
diff --git a/lib/room.h b/lib/room.h
index 75cd7354..aa897b88 100644
--- a/lib/room.h
+++ b/lib/room.h
@@ -202,6 +202,7 @@ namespace QMatrixClient
rev_iter_t readMarker(const User* user) const;
rev_iter_t readMarker() const;
QString readMarkerEventId() const;
+ QList<User*> usersAtEventId(const QString& eventId);
/**
* @brief Mark the event with uptoEventId as read
*