Add comments

pull/404/head
nielsandriesse 5 years ago
parent 2e9eb3b925
commit 438164110c

@ -2,6 +2,7 @@
enum ContactUtilities { enum ContactUtilities {
static func getAllContacts() -> [String] { static func getAllContacts() -> [String] {
// Collect all contacts
var result: [String] = [] var result: [String] = []
Storage.read { transaction in Storage.read { transaction in
TSContactThread.enumerateCollectionObjects(with: transaction) { object, _ in TSContactThread.enumerateCollectionObjects(with: transaction) { object, _ in
@ -12,9 +13,11 @@ enum ContactUtilities {
func getDisplayName(for publicKey: String) -> String { func getDisplayName(for publicKey: String) -> String {
return Storage.shared.getContact(with: publicKey)?.displayName(for: .regular) ?? publicKey return Storage.shared.getContact(with: publicKey)?.displayName(for: .regular) ?? publicKey
} }
// Remove the current user
if let index = result.firstIndex(of: getUserHexEncodedPublicKey()) { if let index = result.firstIndex(of: getUserHexEncodedPublicKey()) {
result.remove(at: index) result.remove(at: index)
} }
// Sort alphabetically
return result.sorted { getDisplayName(for: $0) < getDisplayName(for: $1) } return result.sorted { getDisplayName(for: $0) < getDisplayName(for: $1) }
} }
} }

Loading…
Cancel
Save