mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			21 lines
		
	
	
		
			815 B
		
	
	
	
		
			Swift
		
	
			
		
		
	
	
			21 lines
		
	
	
		
			815 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, thread.shouldThreadBeVisible else { return }
 | |
|                 result.append(thread.contactIdentifier())
 | |
|             }
 | |
|         }
 | |
|         func getDisplayName(for publicKey: String) -> String {
 | |
|             return Storage.shared.getContact(with: publicKey)?.displayName(for: .regular) ?? publicKey
 | |
|         }
 | |
|         if let index = result.firstIndex(of: getUserHexEncodedPublicKey()) {
 | |
|             result.remove(at: index)
 | |
|         }
 | |
|         return result.sorted { getDisplayName(for: $0) < getDisplayName(for: $1) }
 | |
|     }
 | |
| }
 |