From 9ac72c962d2f2b5a3d1a32357edf0e58a3145f11 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Tue, 18 Nov 2025 14:44:56 -0500 Subject: [PATCH] chore: show bot in group chat invite page --- .../pages/pangea_invitation_selection.dart | 31 ++++++++++++------- pubspec.yaml | 2 +- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/pangea/chat_settings/pages/pangea_invitation_selection.dart b/lib/pangea/chat_settings/pages/pangea_invitation_selection.dart index a78b0286e..e02d2c048 100644 --- a/lib/pangea/chat_settings/pages/pangea_invitation_selection.dart +++ b/lib/pangea/chat_settings/pages/pangea_invitation_selection.dart @@ -194,6 +194,10 @@ class PangeaInvitationSelectionController if (a.id == client.userID) return -1; if (b.id == client.userID) return 1; + // sort the bot to the top + if (a.id == BotName.byEnvironment) return -1; + if (b.id == BotName.byEnvironment) return 1; + if (participants != null) { final participantA = participants!.firstWhereOrNull((u) => u.id == a.id); final participantB = participants!.firstWhereOrNull((u) => u.id == b.id); @@ -264,25 +268,27 @@ class PangeaInvitationSelectionController ) .toList(); - contacts.removeWhere((u) => u.id == BotName.byEnvironment); + if (_room?.isSpace ?? false) { + contacts.removeWhere((u) => u.id == BotName.byEnvironment); + } contacts.sort(_sortUsers); return contacts; } List getContacts(BuildContext context) { final client = Matrix.of(context).client; - participants!.removeWhere( - (u) => ![Membership.join, Membership.invite].contains(u.membership), - ); final contacts = client.rooms .where((r) => r.isDirectChat) .map((r) => r.unsafeGetUserFromMemoryOrFallback(r.directChatMatrixID!)) .toList(); - contacts.sort( - (a, b) => a.calcDisplayname().toLowerCase().compareTo( - b.calcDisplayname().toLowerCase(), - ), - ); + + if (_room?.isSpace == false && + !contacts.any((u) => u.id == BotName.byEnvironment)) { + final bot = _room?.unsafeGetUserFromMemoryOrFallback( + BotName.byEnvironment, + ); + if (bot != null) contacts.add(bot); + } return contacts; } @@ -341,7 +347,9 @@ class PangeaInvitationSelectionController } final results = response.results; - results.removeWhere((profile) => profile.userId == BotName.byEnvironment); + if (_room?.isSpace ?? false) { + results.removeWhere((profile) => profile.userId == BotName.byEnvironment); + } setState(() { foundProfiles = List.from(results); @@ -364,8 +372,7 @@ class PangeaInvitationSelectionController foundProfiles.removeWhere( (profile) => - participants?.indexWhere((u) => u.id == profile.userId) != -1 || - BotName.byEnvironment == profile.userId, + participants?.indexWhere((u) => u.id == profile.userId) != -1, ); }); } diff --git a/pubspec.yaml b/pubspec.yaml index e64febf56..9c3f86aa9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ description: Learn a language while texting your friends. # Pangea# publish_to: none # On version bump also increase the build number for F-Droid -version: 4.1.15+5 +version: 4.1.15+6 environment: sdk: ">=3.0.0 <4.0.0"