From 20b17e5f3dd4a842224a5e32f6f546c45384cecf Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Thu, 21 Aug 2025 11:37:08 -0400 Subject: [PATCH] fix: load full participant list when needed (#3782) --- lib/pages/chat/chat.dart | 6 ++++++ lib/pages/chat_details/chat_details.dart | 12 ++++++++++++ lib/pages/chat_list/space_view.dart | 6 ++++++ lib/pangea/spaces/utils/load_participants_util.dart | 1 + lib/utils/client_manager.dart | 1 - 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index b5944b175..b8e277831 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -645,6 +645,12 @@ class ChatController extends State onInsert: onInsert, ); // #Pangea + // Users with assosiated events in the timeline will be loaded into the state + // in-memory cache by getTimeline, but to ensure all users (even those without + // event in the timeline) are loaded, we will request all users. This is important + // for widgets in the chat like the activity participants displays + room.requestParticipants(); + if (visibleEvents.length < 10 && timeline != null) { var prevNumEvents = timeline!.events.length; await requestHistory(); diff --git a/lib/pages/chat_details/chat_details.dart b/lib/pages/chat_details/chat_details.dart index 5a43aed3d..ddd1e2d91 100644 --- a/lib/pages/chat_details/chat_details.dart +++ b/lib/pages/chat_details/chat_details.dart @@ -50,6 +50,18 @@ class ChatDetailsController extends State { String? get roomId => widget.roomId; // #Pangea + @override + void initState() { + super.initState(); + + // Widgets within the chat details page rely on a fully-loaded in-memory + // participants list, so we need to ensure that the participants are loaded + final room = Matrix.of(context).client.getRoomById(widget.roomId); + room?.requestParticipants().then((_) { + if (mounted) setState(() {}); + }); + } + final GlobalKey addConversationBotKey = GlobalKey(); diff --git a/lib/pages/chat_list/space_view.dart b/lib/pages/chat_list/space_view.dart index 2aa967bcc..fe5c5e7db 100644 --- a/lib/pages/chat_list/space_view.dart +++ b/lib/pages/chat_list/space_view.dart @@ -75,6 +75,12 @@ class _SpaceViewState extends State { void initState() { // #Pangea // loadHierarchy(); + // load full participant list into memory to ensure widgets + // that rely on full participants list work as expected + final room = Matrix.of(context).client.getRoomById(widget.spaceId); + room?.requestParticipants().then((_) { + if (mounted) setState(() {}); + }); // If, on launch, this room has had updates to its children, // ensure the hierarchy is properly reloaded diff --git a/lib/pangea/spaces/utils/load_participants_util.dart b/lib/pangea/spaces/utils/load_participants_util.dart index 78faca705..c7c48fb46 100644 --- a/lib/pangea/spaces/utils/load_participants_util.dart +++ b/lib/pangea/spaces/utils/load_participants_util.dart @@ -51,6 +51,7 @@ class LoadParticipantsUtilState extends State { error = null; }); + await widget.space.requestParticipants(); await _cacheLevels(); } catch (err, s) { error = err.toString(); diff --git a/lib/utils/client_manager.dart b/lib/utils/client_manager.dart index 9b6392b1e..c981aae82 100644 --- a/lib/utils/client_manager.dart +++ b/lib/utils/client_manager.dart @@ -131,7 +131,6 @@ abstract class ClientManager { // to postLoad to confirm that these state events are completely loaded EventTypes.RoomPowerLevels, EventTypes.RoomJoinRules, - EventTypes.RoomMember, PangeaEventTypes.rules, PangeaEventTypes.botOptions, PangeaEventTypes.capacity,