fix contacts sorting issue in global search

pull/891/head
Ryan ZHAO 10 months ago
parent 4c0ffdcd25
commit 3f3c7321ad

@ -46,7 +46,12 @@ class GlobalSearchViewController: BaseVC, LibSessionRespondingViewController, UI
try SessionThreadViewModel
.defaultContactsQuery(userPublicKey: getUserHexEncodedPublicKey(db))
.fetchAll(db)
}.defaulting(to: [])
}
.defaulting(to: [])
.sorted {
$0.displayName.lowercased() < $1.displayName.lowercased()
}
var groupedContacts: [String: SectionModel] = [:]
contacts.forEach { contactViewModel in
guard !contactViewModel.threadIsNoteToSelf else {
@ -78,13 +83,13 @@ class GlobalSearchViewController: BaseVC, LibSessionRespondingViewController, UI
return SearchResultData(
state: .defaultContacts,
data: groupedContacts.values.sorted { sectionModel0, sectionModel1 in
let title0 = {
let title0: String = {
switch sectionModel0.model {
case .groupedContacts(let title): return title
default: return ""
}
}()
let title1 = {
let title1: String = {
switch sectionModel1.model {
case .groupedContacts(let title): return title
default: return ""

Loading…
Cancel
Save