mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 23:09:35 +01:00
fix: Search mxid for private chat
This commit is contained in:
parent
5f54057666
commit
b6dca5b7a7
@ -30,14 +30,15 @@ class _NewPrivateChatState extends State<NewPrivateChat> {
|
|||||||
-1;
|
-1;
|
||||||
|
|
||||||
void submitAction(BuildContext context) async {
|
void submitAction(BuildContext context) async {
|
||||||
|
controller.text = controller.text.replaceAll('@', '').trim();
|
||||||
if (controller.text.isEmpty) return;
|
if (controller.text.isEmpty) return;
|
||||||
if (!_formKey.currentState.validate()) return;
|
if (!_formKey.currentState.validate()) return;
|
||||||
final matrix = Matrix.of(context);
|
final matrix = Matrix.of(context);
|
||||||
|
|
||||||
if ('@' + controller.text.trim() == matrix.client.userID) return;
|
if ('@' + controller.text == matrix.client.userID) return;
|
||||||
|
|
||||||
final user = User(
|
final user = User(
|
||||||
'@' + controller.text.trim(),
|
'@' + controller.text,
|
||||||
room: Room(id: '', client: matrix.client),
|
room: Room(id: '', client: matrix.client),
|
||||||
);
|
);
|
||||||
final roomID = await showFutureLoadingDialog(
|
final roomID = await showFutureLoadingDialog(
|
||||||
@ -52,12 +53,9 @@ class _NewPrivateChatState extends State<NewPrivateChat> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void searchUserWithCoolDown(BuildContext context) async {
|
void searchUserWithCoolDown(BuildContext context) async {
|
||||||
if (controller.text.startsWith('@')) {
|
|
||||||
controller.text = controller.text.substring(1);
|
|
||||||
}
|
|
||||||
coolDown?.cancel();
|
coolDown?.cancel();
|
||||||
coolDown = Timer(
|
coolDown = Timer(
|
||||||
Duration(seconds: 1),
|
Duration(milliseconds: 500),
|
||||||
() => searchUser(context, controller.text),
|
() => searchUser(context, controller.text),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -73,14 +71,14 @@ class _NewPrivateChatState extends State<NewPrivateChat> {
|
|||||||
if (loading) return;
|
if (loading) return;
|
||||||
setState(() => loading = true);
|
setState(() => loading = true);
|
||||||
final matrix = Matrix.of(context);
|
final matrix = Matrix.of(context);
|
||||||
final response = await showFutureLoadingDialog(
|
UserSearchResult response;
|
||||||
context: context,
|
try {
|
||||||
future: () => matrix.client.searchUser(text, limit: 10),
|
response = await matrix.client.searchUser(text, limit: 10);
|
||||||
);
|
} catch (_) {}
|
||||||
setState(() => loading = false);
|
setState(() => loading = false);
|
||||||
if (response.result?.results?.isEmpty ?? true) return;
|
if (response?.results?.isEmpty ?? true) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
foundProfiles = List<Profile>.from(response.result.results);
|
foundProfiles = List<Profile>.from(response.results);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user