diff --git a/lib/pages/chat_list/chat_list_item.dart b/lib/pages/chat_list/chat_list_item.dart index 0519258e6..b4d86e924 100644 --- a/lib/pages/chat_list/chat_list_item.dart +++ b/lib/pages/chat_list/chat_list_item.dart @@ -309,7 +309,10 @@ class ChatListItem extends StatelessWidget { child: room.isSpace && room.membership == Membership.join ? Text( L10n.of(context).countChatsAndCountParticipants( - room.spaceChildren.length.toString(), + // #Pangea + // room.spaceChildren.length.toString(), + room.spaceChildCount.toString(), + // Pangea# (room.summary.mJoinedMemberCount ?? 1) .toString(), ), diff --git a/lib/pages/chat_list/space_view.dart b/lib/pages/chat_list/space_view.dart index 68eacc2de..dc8709f02 100644 --- a/lib/pages/chat_list/space_view.dart +++ b/lib/pages/chat_list/space_view.dart @@ -547,8 +547,7 @@ class _SpaceViewState extends State { L10n.of(context).countChatsAndCountParticipants( // #Pangea // room.spaceChildren.length, - (_discoveredChildren?.length ?? 0) + - (joinedRooms?.length ?? 0), + room.spaceChildCount.toString(), // Pangea# room.summary.mJoinedMemberCount ?? 1, ), diff --git a/lib/pangea/extensions/room_children_and_parents_extension.dart b/lib/pangea/extensions/room_children_and_parents_extension.dart index 204accd02..02750f063 100644 --- a/lib/pangea/extensions/room_children_and_parents_extension.dart +++ b/lib/pangea/extensions/room_children_and_parents_extension.dart @@ -1,54 +1,6 @@ part of "pangea_room_extension.dart"; extension ChildrenAndParentsRoomExtension on Room { - //note this only will return rooms that the user has joined or been invited to - List get joinedChildren { - if (!isSpace) return []; - return spaceChildren - .where((child) => child.roomId != null) - .map( - (child) => client.getRoomById(child.roomId!), - ) - .where((child) => child != null) - .cast() - .where( - (child) => child.membership == Membership.join, - ) - .toList(); - } - - Future> getChildRooms() async { - final List children = []; - for (final child in spaceChildren) { - if (child.roomId == null) continue; - final Room? room = client.getRoomById(child.roomId!); - if (room != null) { - children.add(room); - } - } - return children; - } - - //resolve somehow if multiple rooms have the state? - //check logic - Room? firstParentWithState(String stateType) { - if (![PangeaEventTypes.languageSettings, PangeaEventTypes.rules] - .contains(stateType)) { - return null; - } - - for (final parent in pangeaSpaceParents) { - if (parent.getState(stateType) != null) { - return parent; - } - } - for (final parent in pangeaSpaceParents) { - final parentFirstRoom = parent.firstParentWithState(stateType); - if (parentFirstRoom != null) return parentFirstRoom; - } - return null; - } - List get pangeaSpaceParents => client.rooms .where( (r) => r.isSpace, @@ -119,6 +71,15 @@ extension ChildrenAndParentsRoomExtension on Room { } return suggestionStatus; } + + /// The number of child rooms to display for a given space. + int get spaceChildCount => client.rooms + .where( + (r) => spaceChildren.any( + (child) => r.id == child.roomId && !r.isAnalyticsRoom, + ), + ) + .length; } class NestedSpaceError extends Error {