diff --git a/lib/views/invitation_selection.dart b/lib/views/invitation_selection.dart index b5a82e2f..8bc511d0 100644 --- a/lib/views/invitation_selection.dart +++ b/lib/views/invitation_selection.dart @@ -99,11 +99,10 @@ class _InvitationSelectionState extends State { } setState(() { foundProfiles = List.from(response.results); - if ('@$text'.isValidMatrixId && - foundProfiles.indexWhere((profile) => '@$text' == profile.userId) == - -1) { + if (text.isValidMatrixId && + foundProfiles.indexWhere((profile) => text == profile.userId) == -1) { setState(() => foundProfiles = [ - Profile.fromJson({'user_id': '@$text'}), + Profile.fromJson({'user_id': text}), ]); } final participants = room diff --git a/lib/views/new_private_chat.dart b/lib/views/new_private_chat.dart index 13e11e4b..60b447d3 100644 --- a/lib/views/new_private_chat.dart +++ b/lib/views/new_private_chat.dart @@ -51,11 +51,14 @@ class _NewPrivateChatState extends State { } } - void searchUserWithCoolDown(BuildContext context, String text) async { + void searchUserWithCoolDown(BuildContext context) async { + if (controller.text.startsWith('@')) { + controller.text = controller.text.substring(1); + } coolDown?.cancel(); coolDown = Timer( Duration(seconds: 1), - () => searchUser(context, text), + () => searchUser(context, controller.text), ); } @@ -99,8 +102,7 @@ class _NewPrivateChatState extends State { controller: controller, autofocus: true, autocorrect: false, - onChanged: (String text) => - searchUserWithCoolDown(context, text), + onChanged: (String text) => searchUserWithCoolDown(context), textInputAction: TextInputAction.go, onFieldSubmitted: (s) => submitAction(context), validator: (value) {