mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
af543b980b
Stopped configuration messages from automatically creating threads for sync'ed contacts (now they will only be created if there are messages) Updated the ConfigurationMessage to stop truncating the list of contacts but filter the full set (also update the logic to include previously approved contacts)
36 lines
1.4 KiB
Swift
36 lines
1.4 KiB
Swift
|
|
enum ContactUtilities {
|
|
|
|
static func getAllContacts() -> [String] {
|
|
// Collect all contacts
|
|
var result: [String] = []
|
|
Storage.read { transaction in
|
|
// FIXME: If a user deletes a contact thread they will no longer appear in this list (ie. won't be an option for closed group conversations)
|
|
TSContactThread.enumerateCollectionObjects(with: transaction) { object, _ in
|
|
guard
|
|
let thread: TSContactThread = object as? TSContactThread,
|
|
thread.shouldBeVisible,
|
|
Storage.shared.getContact(
|
|
with: thread.contactSessionID(),
|
|
using: transaction
|
|
)?.didApproveMe == true
|
|
else {
|
|
return
|
|
}
|
|
|
|
result.append(thread.contactSessionID())
|
|
}
|
|
}
|
|
func getDisplayName(for publicKey: String) -> String {
|
|
return Storage.shared.getContact(with: publicKey)?.displayName(for: .regular) ?? publicKey
|
|
}
|
|
|
|
// Remove the current user
|
|
if let index = result.firstIndex(of: getUserHexEncodedPublicKey()) {
|
|
result.remove(at: index)
|
|
}
|
|
|
|
// Sort alphabetically
|
|
return result.sorted { getDisplayName(for: $0) < getDisplayName(for: $1) }
|
|
}
|
|
}
|