diff --git a/lib/data/models/contact_cubit.dart b/lib/data/models/contact_cubit.dart index cd38fd44af9bddccff6dafa7e6beeb9a2f912e22..bdd203ec29d9fd6d128edf91daf71cfab5926dd4 100644 --- a/lib/data/models/contact_cubit.dart +++ b/lib/data/models/contact_cubit.dart @@ -113,12 +113,15 @@ class ContactsCubit extends HydratedCubit<ContactsState> { } void sortContacts(ContactsSortType sortOrder) { - List<Contact> sortedContacts = List<Contact>.from(state.contacts); + List<Contact> sortedContacts = List<Contact>.from(state.filteredContacts); if (sortOrder == ContactsSortType.alpha) { sortContactList(sortedContacts); } else if (sortOrder == ContactsSortType.date) { - sortedContacts = List<Contact>.from(state.contacts); + sortedContacts = List<Contact>.from(state.contacts).where((Contact c) { + return state.filteredContacts + .any((Contact fc) => fc.pubKey == c.pubKey); + }).toList(); } emit(state.copyWith(filteredContacts: sortedContacts, order: sortOrder));