From a48e46dd315c66c196626f280cedbf4f0fa52355 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Wed, 25 May 2016 20:00:28 +0900 Subject: Load a different set of event lists depending on the join state (and actually introduce EventList class) This makes loading of room events more compliant with the spec, not trying to load from keys that are not supposed to be there. As a result of refactoring along the way, a dedicated QList subclass is made that remembers the JSON key it should load from and actually load itself from a QJsonArray. --- jobs/syncjob.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'jobs/syncjob.h') diff --git a/jobs/syncjob.h b/jobs/syncjob.h index 507d46eb..abbef23a 100644 --- a/jobs/syncjob.h +++ b/jobs/syncjob.h @@ -30,12 +30,22 @@ namespace QMatrixClient class SyncRoomData { public: + class EventList : public QList + { + private: + QString jsonKey; + public: + explicit EventList(QString k) : jsonKey(k) { } + void fromJson(const QJsonObject& roomContents); + }; + QString roomId; JoinState joinState; - QList state; - QList timeline; - QList ephemeral; - QList accountData; + EventList state; + EventList timeline; + EventList ephemeral; + EventList accountData; + EventList inviteState; bool timelineLimited; QString timelinePrevBatch; -- cgit v1.2.3