From bc83e269b8f64f5d0e712bf245d05925573e84d9 Mon Sep 17 00:00:00 2001 From: Black Hat Date: Wed, 29 Aug 2018 19:54:17 +0800 Subject: Use local QHash. --- lib/room.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/room.cpp') 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 usersTyping; + QHash> eventIdReadUsers; QList 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 Room::usersAtEventId(const QString& eventId) { + if (!d->eventIdReadUsers.contains(eventId)) return QList(); + return d->eventIdReadUsers[eventId]; +} + int Room::notificationCount() const { return d->notificationCount; -- cgit v1.2.3 From a76e13b7411f7d09fdefca368e085a2e3e885903 Mon Sep 17 00:00:00 2001 From: Black Hat Date: Wed, 29 Aug 2018 20:17:37 +0800 Subject: Use QMultiHash. --- lib/room.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/room.cpp') diff --git a/lib/room.cpp b/lib/room.cpp index bb15760a..90306b23 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -103,7 +103,7 @@ class Room::Private int notificationCount = 0; members_map_t membersMap; QList usersTyping; - QHash> eventIdReadUsers; + QMultiHash eventIdReadUsers; QList membersLeft; int unreadMessages = 0; bool displayed = false; @@ -377,8 +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); + eventIdReadUsers.remove(storedId, u); + eventIdReadUsers.insert(eventId, u); swap(storedId, eventId); emit q->lastReadEventChanged(u); if (isLocalUser(u)) @@ -641,7 +641,7 @@ QString Room::readMarkerEventId() const QList Room::usersAtEventId(const QString& eventId) { if (!d->eventIdReadUsers.contains(eventId)) return QList(); - return d->eventIdReadUsers[eventId]; + return d->eventIdReadUsers.values(eventId); } int Room::notificationCount() const -- cgit v1.2.3 From dd84d4876fb201fb2cdf6149340d5a0da06dcafb Mon Sep 17 00:00:00 2001 From: Black Hat Date: Thu, 30 Aug 2018 18:44:28 +0800 Subject: Remove unused check. --- lib/room.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/room.cpp') diff --git a/lib/room.cpp b/lib/room.cpp index 90306b23..90b01e6c 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -640,7 +640,6 @@ QString Room::readMarkerEventId() const } QList Room::usersAtEventId(const QString& eventId) { - if (!d->eventIdReadUsers.contains(eventId)) return QList(); return d->eventIdReadUsers.values(eventId); } -- cgit v1.2.3 From 79f338877dec3de5ec7394f190025395877cb00b Mon Sep 17 00:00:00 2001 From: Black Hat Date: Thu, 30 Aug 2018 22:11:23 +0800 Subject: Add signal for read receipt. --- lib/room.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/room.cpp') diff --git a/lib/room.cpp b/lib/room.cpp index 90b01e6c..a22f477b 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -381,6 +381,7 @@ void Room::Private::setLastReadEvent(User* u, QString eventId) eventIdReadUsers.insert(eventId, u); swap(storedId, eventId); emit q->lastReadEventChanged(u); + emit q->readMarkerForUserMoved(u, eventId, storedId); if (isLocalUser(u)) { if (storedId != serverReadMarker) -- cgit v1.2.3