From 9272d21ce6e5439444794e6da58e08421e8973db Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 8 Dec 2018 15:37:16 +0900 Subject: Room summaries --- lib/syncdata.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/syncdata.h') diff --git a/lib/syncdata.h b/lib/syncdata.h index aa8948bc..81a91ffc 100644 --- a/lib/syncdata.h +++ b/lib/syncdata.h @@ -22,11 +22,30 @@ #include "events/stateevent.h" namespace QMatrixClient { + struct RoomSummary + { + int joinedMemberCount = 0; + int invitedMemberCount = 0; + QStringList heroes; //< mxids of users to take part in the room name + + bool operator==(const RoomSummary& other) const; + bool operator!=(const RoomSummary& other) const + { return !(*this == other); } + }; + + template <> + struct JsonObjectConverter + { + static void dumpTo(QJsonObject& jo, const RoomSummary& rs); + static void fillFrom(const QJsonObject& jo, RoomSummary& rs); + }; + class SyncRoomData { public: QString roomId; JoinState joinState; + RoomSummary summary; StateEvents state; RoomEvents timeline; Events ephemeral; -- cgit v1.2.3 From d51684b759f686b2c9895c5013dce88fead9661b Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 8 Dec 2018 22:42:25 +0900 Subject: MSC 688: MSC-compliant RoomSummary; update Room::calculateDisplayname() The members of the summary can be omitted in the payload; this change fixes calculation of the roomname from hero names passed in room summary. Also: RoomSummary can be dumped to QDebug now. --- lib/syncdata.h | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'lib/syncdata.h') diff --git a/lib/syncdata.h b/lib/syncdata.h index 81a91ffc..663553bc 100644 --- a/lib/syncdata.h +++ b/lib/syncdata.h @@ -22,15 +22,26 @@ #include "events/stateevent.h" namespace QMatrixClient { + /// Room summary, as defined in MSC688 + /** + * Every member of this structure is an Omittable; as per the MSC, only + * changed values are sent from the server so if nothing is in the payload + * the respective member will be omitted. In particular, `heroes.omitted()` + * means that nothing has come from the server; heroes.value().isEmpty() + * means a peculiar case of a room with the only member - the current user. + */ struct RoomSummary { - int joinedMemberCount = 0; - int invitedMemberCount = 0; - QStringList heroes; //< mxids of users to take part in the room name + Omittable joinedMemberCount; + Omittable invitedMemberCount; + Omittable heroes; //< mxids of users to take part in the room name - bool operator==(const RoomSummary& other) const; - bool operator!=(const RoomSummary& other) const - { return !(*this == other); } + bool isEmpty() const; + /// Merge the contents of another RoomSummary object into this one + /// \return true, if the current object has changed; false otherwise + bool merge(const RoomSummary& other); + + friend QDebug operator<<(QDebug dbg, const RoomSummary& rs); }; template <> -- cgit v1.2.3 From 07c9eacc0d0009040e359fd822674a48ef8edeac Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 13 Dec 2018 07:59:45 +0900 Subject: Bump room state cache version to reset the cache --- lib/syncdata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/syncdata.h') diff --git a/lib/syncdata.h b/lib/syncdata.h index 663553bc..8694626e 100644 --- a/lib/syncdata.h +++ b/lib/syncdata.h @@ -100,7 +100,7 @@ namespace QMatrixClient { QStringList unresolvedRooms() const { return unresolvedRoomIds; } - static std::pair cacheVersion() { return { 9, 0 }; } + static std::pair cacheVersion() { return { 10, 0 }; } static QString fileNameForRoom(QString roomId); private: -- cgit v1.2.3