fix: normalize space chat count copy (#1829)
This commit is contained in:
parent
beb0e91c07
commit
8176d691bf
3 changed files with 14 additions and 51 deletions
|
|
@ -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(),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -547,8 +547,7 @@ class _SpaceViewState extends State<SpaceView> {
|
|||
L10n.of(context).countChatsAndCountParticipants(
|
||||
// #Pangea
|
||||
// room.spaceChildren.length,
|
||||
(_discoveredChildren?.length ?? 0) +
|
||||
(joinedRooms?.length ?? 0),
|
||||
room.spaceChildCount.toString(),
|
||||
// Pangea#
|
||||
room.summary.mJoinedMemberCount ?? 1,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -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<Room> get joinedChildren {
|
||||
if (!isSpace) return [];
|
||||
return spaceChildren
|
||||
.where((child) => child.roomId != null)
|
||||
.map(
|
||||
(child) => client.getRoomById(child.roomId!),
|
||||
)
|
||||
.where((child) => child != null)
|
||||
.cast<Room>()
|
||||
.where(
|
||||
(child) => child.membership == Membership.join,
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
|
||||
Future<List<Room>> getChildRooms() async {
|
||||
final List<Room> 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<Room> 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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue