aboutsummaryrefslogtreecommitdiff
path: root/lib/events/receiptevent.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-11-15 21:51:51 +0100
committerKitsune Ral <Kitsune-Ral@users.sf.net>2020-11-15 21:51:51 +0100
commit52cab4b11bdd48cd87e04c01b12c698ec4145e6d (patch)
treef8b44dd9c585606b4ac229c396ef914d5950fd47 /lib/events/receiptevent.cpp
parent5b1bfc102fccd4e57893b34bf2b0a14ba6a9f577 (diff)
downloadlibquotient-52cab4b11bdd48cd87e04c01b12c698ec4145e6d.tar.gz
libquotient-52cab4b11bdd48cd87e04c01b12c698ec4145e6d.zip
Cleanup across event classes
In particular: removed unnecessary #includes, deprecated and no more used constructs, replaced stored members with dynamic generation from JSON (TypingEvent and, especially promising for performance, ReceiptEvent)
Diffstat (limited to 'lib/events/receiptevent.cpp')
-rw-r--r--lib/events/receiptevent.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/events/receiptevent.cpp b/lib/events/receiptevent.cpp
index bf050cb2..deb3c4e8 100644
--- a/lib/events/receiptevent.cpp
+++ b/lib/events/receiptevent.cpp
@@ -40,10 +40,11 @@ Example of a Receipt Event:
using namespace Quotient;
-ReceiptEvent::ReceiptEvent(const QJsonObject& obj) : Event(typeId(), obj)
+EventsWithReceipts ReceiptEvent::eventsWithReceipts() const
{
+ EventsWithReceipts result;
const auto& contents = contentJson();
- _eventsWithReceipts.reserve(contents.size());
+ result.reserve(contents.size());
for (auto eventIt = contents.begin(); eventIt != contents.end(); ++eventIt) {
if (eventIt.key().isEmpty()) {
qCWarning(EPHEMERAL)
@@ -51,15 +52,16 @@ ReceiptEvent::ReceiptEvent(const QJsonObject& obj) : Event(typeId(), obj)
qCDebug(EPHEMERAL) << "ReceiptEvent content follows:\n" << contents;
continue;
}
- const QJsonObject reads =
+ const auto reads =
eventIt.value().toObject().value("m.read"_ls).toObject();
QVector<Receipt> receipts;
receipts.reserve(reads.size());
for (auto userIt = reads.begin(); userIt != reads.end(); ++userIt) {
- const QJsonObject user = userIt.value().toObject();
+ const auto user = userIt.value().toObject();
receipts.push_back(
{ userIt.key(), fromJson<QDateTime>(user["ts"_ls]) });
}
- _eventsWithReceipts.push_back({ eventIt.key(), std::move(receipts) });
+ result.push_back({ eventIt.key(), std::move(receipts) });
}
+ return result;
}