allow user to simply search for username without prefix and suffix (#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 <46800240+ggurdin@users.noreply.github.com>
This commit is contained in:
parent
6540885100
commit
420a5dc4a7
3 changed files with 36 additions and 5 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
@ -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))),
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue