From c18a49915b4b98ac7f837a1feca3e243ac44940d Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Sat, 28 Oct 2017 20:46:34 +0300 Subject: Save the changes between syncs in cache - Fixes high cpu issues caused by the serialization of the whole in-memory state. - Display name changes are now visible in the timeline. --- include/ChatPage.h | 24 +++++++++++++++++++++++- include/RoomState.h | 6 +++++- 2 files changed, 28 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/ChatPage.h b/include/ChatPage.h index d3790f78..416f7870 100644 --- a/include/ChatPage.h +++ b/include/ChatPage.h @@ -23,6 +23,10 @@ #include #include +#include "MemberEventContent.h" +#include "MessageEvent.h" +#include "StateEvent.h" + class Cache; class MatrixClient; class OverlayModal; @@ -38,6 +42,8 @@ class TimelineViewManager; class TopRoomBar; class TypingDisplay; class UserInfoWidget; +class JoinedRoom; +class LeftRoom; constexpr int CONSENSUS_TIMEOUT = 1000; constexpr int SHOW_CONTENT_TIMEOUT = 3000; @@ -76,8 +82,24 @@ private slots: void removeRoom(const QString &room_id); private: + using UserID = QString; + using RoomStates = QMap; + using JoinedRooms = QMap; + using LeftRooms = QMap; + using Membership = matrix::events::StateEvent; + using Memberships = QMap; + + void removeLeftRooms(const LeftRooms &rooms); + void updateJoinedRooms(const JoinedRooms &rooms); + + Memberships getMemberships(const QJsonArray &events) const; + RoomStates generateMembershipDifference(const JoinedRooms &rooms, + const RoomStates &states) const; + void updateTypingUsers(const QString &roomid, const QList &user_ids); - void updateDisplayNames(const RoomState &state); + void updateUserMetadata(const QJsonArray &events); + void updateUserDisplayName(const Membership &event); + void updateUserAvatarUrl(const Membership &event); void loadStateFromCache(); void deleteConfigs(); void resetUI(); diff --git a/include/RoomState.h b/include/RoomState.h index 57955e56..db1cdc68 100644 --- a/include/RoomState.h +++ b/include/RoomState.h @@ -41,6 +41,9 @@ namespace events = matrix::events; class RoomState { public: + RoomState(); + RoomState(const QJsonArray &events); + // Calculate room data that are not immediatly accessible. Like room name and // avatar. // @@ -71,7 +74,8 @@ public: events::StateEvent topic; // Contains the m.room.member events for all the joined users. - QMap> memberships; + using UserID = QString; + QMap> memberships; private: QUrl avatar_; -- cgit 1.5.1