mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
18 lines
657 B
Swift
18 lines
657 B
Swift
|
|
||
|
enum ContactUtilities {
|
||
|
|
||
|
static func getAllContacts() -> [String] {
|
||
|
var result: [String] = []
|
||
|
Storage.read { transaction in
|
||
|
TSContactThread.enumerateCollectionObjects(with: transaction) { object, _ in
|
||
|
guard let thread = object as? TSContactThread else { return }
|
||
|
result.append(thread.contactIdentifier())
|
||
|
}
|
||
|
}
|
||
|
func getDisplayName(for publicKey: String) -> String {
|
||
|
return UserDisplayNameUtilities.getPrivateChatDisplayName(for: publicKey) ?? publicKey
|
||
|
}
|
||
|
return result.sorted { getDisplayName(for: $0) < getDisplayName(for: $1) }
|
||
|
}
|
||
|
}
|