From 744c6f1b3ff772e55468faebfe3b8cd096dd61f9 Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 16 Apr 2020 16:08:35 -0400 Subject: [PATCH] Load all room members when showing a room to user --- src/backend/matrix_client.py | 7 +++++++ src/gui/Pages/Chat/ChatPage.qml | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index 5c25713f..00f032d3 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -740,6 +740,13 @@ class MatrixClient(nio.AsyncClient): ) + async def load_all_room_members(self, room_id: str) -> None: + room = self.all_rooms[room_id] + + if not room.members_synced: + await super().joined_members(room_id) + + async def load_past_events(self, room_id: str) -> bool: """Ask the server for 100 previous events of the room. diff --git a/src/gui/Pages/Chat/ChatPage.qml b/src/gui/Pages/Chat/ChatPage.qml index 0dadaaca..80251d13 100644 --- a/src/gui/Pages/Chat/ChatPage.qml +++ b/src/gui/Pages/Chat/ChatPage.qml @@ -13,9 +13,11 @@ HColumnPage { rightPadding: 0 onLoadEventListChanged: if (loadEventList) loadedOnce = true + Component.onDestruction: if (loadMembersFuture) loadMembersFuture.cancel() property bool loadedOnce: false + property var loadMembersFuture: null readonly property alias composer: composer readonly property bool loadEventList: @@ -23,6 +25,17 @@ HColumnPage { ! mainUI.mainPane.visible : ! pageLoader.appearAnimation.running + Timer { + interval: 200 + running: true + onTriggered: loadMembersFuture = py.callClientCoro( + chat.userId, + "load_all_room_members", + [chat.roomId], + () => { loadMembersFuture = null }, + ) + } + RoomHeader { Layout.fillWidth: true }