diff --git a/lib/presentation/mixins/contacts_view_controller_mixin.dart b/lib/presentation/mixins/contacts_view_controller_mixin.dart index 75b6390ce..c5528fade 100644 --- a/lib/presentation/mixins/contacts_view_controller_mixin.dart +++ b/lib/presentation/mixins/contacts_view_controller_mixin.dart @@ -236,17 +236,23 @@ mixin class ContactsViewControllerMixin { contactsManager.getContactsNotifier().value.fold( (failure) { if (failure is GetContactsFailure) { - return Left( - GetPresentationContactsFailure( - keyword: keyword, + return _handleSearchExternalContact( + keyword, + otherResult: Left( + GetPresentationContactsFailure( + keyword: keyword, + ), ), ); } if (failure is GetContactsIsEmpty) { - return Left( - GetPresentationContactsEmpty( - keyword: keyword, + return _handleSearchExternalContact( + keyword, + otherResult: Left( + GetPresentationContactsEmpty( + keyword: keyword, + ), ), ); } @@ -296,17 +302,23 @@ mixin class ContactsViewControllerMixin { contactsManager.getPhonebookContactsNotifier().value.fold( (failure) { if (failure is GetPhonebookContactsFailure) { - return Left( - GetPresentationContactsFailure( - keyword: keyword, + return _handleSearchExternalContact( + keyword, + otherResult: Left( + GetPresentationContactsFailure( + keyword: keyword, + ), ), ); } if (failure is GetPhonebookContactsIsEmpty) { - return Left( - GetPresentationContactsEmpty( - keyword: keyword, + return _handleSearchExternalContact( + keyword, + otherResult: Left( + GetPresentationContactsEmpty( + keyword: keyword, + ), ), ); } @@ -338,6 +350,25 @@ mixin class ContactsViewControllerMixin { ); } + Either _handleSearchExternalContact( + String keyword, { + required Either otherResult, + }) { + if (keyword.isValidMatrixId && keyword.startsWith("@")) { + return Right( + PresentationExternalContactSuccess( + contact: PresentationContact( + matrixId: keyword, + displayName: keyword.substring(1), + type: ContactType.external, + ), + ), + ); + } else { + return otherResult; + } + } + Future _refreshRecentContacts({ required Client client, required MatrixLocalizations matrixLocalizations,