diff options
Diffstat (limited to 'jobs/syncjob.h')
-rw-r--r-- | jobs/syncjob.h | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/jobs/syncjob.h b/jobs/syncjob.h index aed36e0b..5956e73b 100644 --- a/jobs/syncjob.h +++ b/jobs/syncjob.h @@ -26,30 +26,30 @@ namespace QMatrixClient { - class SyncRoomData + template <typename EventT> + class SyncBatch : public EventsBatch<EventT> { public: - template <typename EventT> - class Batch : public EventsBatch<EventT> + explicit SyncBatch(QString k) : jsonKey(std::move(k)) { } + void fromJson(const QJsonObject& roomContents) { - public: - explicit Batch(QString k) : jsonKey(std::move(k)) { } - void fromJson(const QJsonObject& roomContents) - { - EventsBatch<EventT>::fromJson( - roomContents[jsonKey].toObject(), "events"); - } + EventsBatch<EventT>::fromJson( + roomContents[jsonKey].toObject(), "events"); + } - private: - QString jsonKey; - }; + private: + QString jsonKey; + }; + class SyncRoomData + { + public: QString roomId; JoinState joinState; - Batch<RoomEvent> state; - Batch<RoomEvent> timeline; - Batch<Event> ephemeral; - Batch<Event> accountData; + SyncBatch<RoomEvent> state; + SyncBatch<RoomEvent> timeline; + SyncBatch<Event> ephemeral; + SyncBatch<Event> accountData; bool timelineLimited; QString timelinePrevBatch; @@ -68,11 +68,13 @@ namespace QMatrixClient { public: BaseJob::Status parseJson(const QJsonDocument &data); + SyncBatch<Event>&& takeAccountData(); SyncDataList&& takeRoomData(); QString nextBatch() const; private: QString nextBatch_; + SyncBatch<Event> accountData { "account_data" }; SyncDataList roomData; }; |