diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-11-16 14:10:08 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-11-16 14:10:08 +0900 |
commit | 491e392af73be3ebfd928e80efc0514fd43b8e87 (patch) | |
tree | b129a00585a19764ef4092fe381c56c4658cd478 /jobs | |
parent | f12e09ea1b45be1a96533aa83f6227940c70d548 (diff) | |
download | libquotient-491e392af73be3ebfd928e80efc0514fd43b8e87.tar.gz libquotient-491e392af73be3ebfd928e80efc0514fd43b8e87.zip |
Simplify code that loads events from JSON arrays
Diffstat (limited to 'jobs')
-rw-r--r-- | jobs/roommessagesjob.cpp | 4 | ||||
-rw-r--r-- | jobs/syncjob.h | 5 |
2 files changed, 4 insertions, 5 deletions
diff --git a/jobs/roommessagesjob.cpp b/jobs/roommessagesjob.cpp index 078c692a..c527cc71 100644 --- a/jobs/roommessagesjob.cpp +++ b/jobs/roommessagesjob.cpp @@ -58,8 +58,8 @@ QString RoomMessagesJob::end() const BaseJob::Status RoomMessagesJob::parseJson(const QJsonDocument& data) { - QJsonObject obj = data.object(); - d->events.assign(makeEvents<RoomEvent>(obj.value("chunk").toArray())); + const auto obj = data.object(); + d->events.fromJson(obj, "chunk"); d->end = obj.value("end").toString(); return Success; } diff --git a/jobs/syncjob.h b/jobs/syncjob.h index b1db914d..08bd773e 100644 --- a/jobs/syncjob.h +++ b/jobs/syncjob.h @@ -36,11 +36,10 @@ namespace QMatrixClient explicit Batch(QString k) : jsonKey(std::move(k)) { } void fromJson(const QJsonObject& roomContents) { - this->assign(makeEvents<EventT>( - roomContents[jsonKey].toObject()["events"].toArray())); + EventsBatch<EventT>::fromJson( + roomContents[jsonKey].toObject(), "events"); } - private: QString jsonKey; }; |