Skip to content

Commit

Permalink
allow user to simply search for username without prefix and suffix (#…
Browse files Browse the repository at this point in the history
…1761)

* allow user to simply search for username without prefix and suffix

* remove debug print

* generated

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: ggurdin <[email protected]>
  • Loading branch information
3 people authored Feb 10, 2025
1 parent 6540885 commit 420a5dc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/config/app_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract class AppConfig {
static String? get applicationWelcomeMessage => _applicationWelcomeMessage;
// #Pangea
// static String _defaultHomeserver = 'matrix.org';
static String _defaultHomeserver = Environment.synapsURL;
static String _defaultHomeserver = Environment.synapseURL;
// #Pangea
static String get defaultHomeserver => _defaultHomeserver;
static double fontSizeFactor = 1;
Expand Down
16 changes: 15 additions & 1 deletion lib/pages/invitation_selection/invitation_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:matrix/matrix.dart';

import 'package:fluffychat/pages/invitation_selection/invitation_selection_view.dart';
import 'package:fluffychat/pangea/bot/utils/bot_name.dart';
import 'package:fluffychat/pangea/common/config/environment.dart';
import 'package:fluffychat/widgets/future_loading_dialog.dart';
import 'package:fluffychat/widgets/matrix.dart';
import '../../utils/localized_exception_extension.dart';
Expand Down Expand Up @@ -171,12 +172,25 @@ class InvitationSelectionController extends State<InvitationSelection> {
}
currentSearchTerm = text;
if (currentSearchTerm.isEmpty) return;
//#Pangea
String pangeaSearchText = text;
if (!pangeaSearchText.startsWith("@")) {
pangeaSearchText = "@$pangeaSearchText";
}
if (!pangeaSearchText.contains(":")) {
pangeaSearchText = "$pangeaSearchText:${Environment.homeServer}";
}
//#Pangea
if (loading) return;
setState(() => loading = true);
final matrix = Matrix.of(context);
SearchUserDirectoryResponse response;
try {
response = await matrix.client.searchUserDirectory(text, limit: 10);
// response = await matrix.client.searchUserDirectory(text, limit: 10);
//#Pangea
response =
await matrix.client.searchUserDirectory(pangeaSearchText, limit: 10);
//#Pangea
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text((e).toLocalizedString(context))),
Expand Down
23 changes: 20 additions & 3 deletions lib/pangea/common/config/environment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,35 @@ class Environment {
return ".env";
}

static bool get isStaging => synapsURL.contains("staging");
static bool get isStaging => synapseURL.contains("staging");

static String get frontendURL {
return dotenv.env["FRONTEND_URL"] ?? "Frontend URL NOT FOUND";
}

static String get synapsURL {
static String get synapseURL {
return dotenv.env['SYNAPSE_URL'] ?? 'Synapse Url not found';
}

static String get homeServer {
return dotenv.env["HOME_SERVER"] ?? 'Home Server not found';
String? homeServerFromSynapseURL = dotenv.env['SYNAPSE_URL'];
if (homeServerFromSynapseURL != null) {
if (homeServerFromSynapseURL.startsWith("http://")) {
homeServerFromSynapseURL =
homeServerFromSynapseURL.replaceFirst("http://", "");
}
if (homeServerFromSynapseURL.startsWith("https://")) {
homeServerFromSynapseURL =
homeServerFromSynapseURL.replaceFirst("https://", "");
}
if (homeServerFromSynapseURL.startsWith("matrix.")) {
homeServerFromSynapseURL =
homeServerFromSynapseURL.replaceFirst("matrix.", "");
}
}
return dotenv.env["HOME_SERVER"] ??
homeServerFromSynapseURL ??
'Home Server not found';
}

static String get choreoApi {
Expand Down

0 comments on commit 420a5dc

Please sign in to comment.