Skip to content

Commit

Permalink
TW-1152: Support can search by email on chat list
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev authored and hoangdat committed Feb 19, 2024
1 parent 134a4db commit b41993f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/pages/search/search_contacts_and_chats_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,25 @@ class SearchContactsAndChatsController with SearchDebouncerMixin {
final recentChatPresentationSearchMatched = tomPresentationSearchContacts
.expand((contact) => contact.toPresentationSearch())
.where((contact) {
return contact.displayName!.toLowerCase().contains(keyword.toLowerCase());
if (contact is! ContactPresentationSearch) {
return false;
}

if (contact.displayName == null) {
return false;
}

if (contact.email == null) {
return false;
}

final matchedName =
contact.displayName!.toLowerCase().contains(keyword.toLowerCase());

final matchedEmail =
contact.email!.toLowerCase().contains(keyword.toLowerCase());

return matchedName || matchedEmail;
}).toList();
_searchRecentChatInteractor
.execute(
Expand Down
4 changes: 4 additions & 0 deletions lib/pages/search/search_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ class SearchView extends StatelessWidget {
searchController.serverSearchController.searchResultsNotifier,
builder: ((context, searchResults, child) {
if (searchResults is PresentationServerSideEmptySearch) {
if (searchController.searchContactAndRecentChatController!
.recentAndContactsNotifier.value.isNotEmpty) {
return child!;
}
return _SearchHeader(
header: L10n.of(context)!.messages,
searchController: searchController,
Expand Down
4 changes: 4 additions & 0 deletions lib/pages/search/server_search_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class ServerSearchMessagesList extends StatelessWidget {
searchController.serverSearchController.searchResultsNotifier,
builder: (context, serverSearchNotifier, child) {
if (serverSearchNotifier is PresentationServerSideEmptySearch) {
if (searchController.searchContactAndRecentChatController!
.recentAndContactsNotifier.value.isNotEmpty) {
return const SizedBox.shrink();
}
return child!;
}

Expand Down

0 comments on commit b41993f

Please sign in to comment.