mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 11:05:10 +00:00
chore: Follow up new chat: Add mxid if not found
This commit is contained in:
parent
83ce07c574
commit
e4e399b69b
2 changed files with 19 additions and 6 deletions
|
@ -27,7 +27,7 @@ class NewPrivateChatController extends State<NewPrivateChat> {
|
|||
final TextEditingController controller = TextEditingController();
|
||||
final FocusNode textFieldFocus = FocusNode();
|
||||
|
||||
Future<SearchUserDirectoryResponse>? searchResponse;
|
||||
Future<List<Profile>>? searchResponse;
|
||||
|
||||
Timer? _searchCoolDown;
|
||||
|
||||
|
@ -46,12 +46,25 @@ class NewPrivateChatController extends State<NewPrivateChat> {
|
|||
_searchCoolDown?.cancel();
|
||||
_searchCoolDown = Timer(_coolDown, () {
|
||||
setState(() {
|
||||
searchResponse =
|
||||
Matrix.of(context).client.searchUserDirectory(searchTerm);
|
||||
searchResponse = _searchUser(searchTerm);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Future<List<Profile>> _searchUser(String searchTerm) async {
|
||||
final result =
|
||||
await Matrix.of(context).client.searchUserDirectory(searchTerm);
|
||||
final profiles = result.results;
|
||||
|
||||
if (searchTerm.isValidMatrixId &&
|
||||
searchTerm.sigil == '@' &&
|
||||
!profiles.any((profile) => profile.userId == searchTerm)) {
|
||||
profiles.add(Profile(userId: searchTerm));
|
||||
}
|
||||
|
||||
return profiles;
|
||||
}
|
||||
|
||||
void inviteAction() => FluffyShare.shareInviteLink(context);
|
||||
|
||||
void openScannerAction() async {
|
||||
|
|
|
@ -205,7 +205,7 @@ class NewPrivateChatView extends StatelessWidget {
|
|||
child: CircularProgressIndicator.adaptive(),
|
||||
);
|
||||
}
|
||||
if (result.results.isEmpty) {
|
||||
if (result.isEmpty) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
|
@ -226,9 +226,9 @@ class NewPrivateChatView extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
return ListView.builder(
|
||||
itemCount: result.results.length,
|
||||
itemCount: result.length,
|
||||
itemBuilder: (context, i) {
|
||||
final contact = result.results[i];
|
||||
final contact = result[i];
|
||||
final displayname = contact.displayName ??
|
||||
contact.userId.localpart ??
|
||||
contact.userId;
|
||||
|
|
Loading…
Reference in a new issue