diff options
Diffstat (limited to 'jobs/syncjob.h')
-rw-r--r-- | jobs/syncjob.h | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/jobs/syncjob.h b/jobs/syncjob.h index 48be9423..07824e23 100644 --- a/jobs/syncjob.h +++ b/jobs/syncjob.h @@ -20,39 +20,46 @@ #include "basejob.h" -#include "../joinstate.h" -#include "../events/event.h" +#include "joinstate.h" +#include "events/event.h" #include "util.h" namespace QMatrixClient { class SyncRoomData { - public: - class EventList : public Owning<Events> - { - private: - QString jsonKey; - public: - explicit EventList(QString k) : jsonKey(std::move(k)) { } - void fromJson(const QJsonObject& roomContents); - }; + public: + template <typename EventT> + class Batch : public Owning<EventsBatch<EventT>> + { + public: + explicit Batch(QString k) : jsonKey(std::move(k)) { } + void fromJson(const QJsonObject& roomContents) + { + this->assign(makeEvents<EventT>( + roomContents[jsonKey].toObject()["events"].toArray())); + } + + + private: + QString jsonKey; + }; - QString roomId; - JoinState joinState; - EventList state; - EventList timeline; - EventList ephemeral; - EventList accountData; - EventList inviteState; + QString roomId; + JoinState joinState; + Batch<RoomEvent> state; + Batch<RoomEvent> timeline; + Batch<Event> ephemeral; + Batch<Event> accountData; + Batch<Event> inviteState; - bool timelineLimited; - QString timelinePrevBatch; - int highlightCount; - int notificationCount; + bool timelineLimited; + QString timelinePrevBatch; + int highlightCount; + int notificationCount; - SyncRoomData(const QString& roomId, JoinState joinState_, - const QJsonObject& room_); + SyncRoomData(const QString& roomId, JoinState joinState_, + const QJsonObject& room_); }; } // namespace QMatrixClient Q_DECLARE_TYPEINFO(QMatrixClient::SyncRoomData, Q_MOVABLE_TYPE); |