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
		
	
	
		
			811 B
		
	
	
	
		
			Swift
		
	
		
		
			
		
	
	
			21 lines
		
	
	
		
			811 B
		
	
	
	
		
			Swift
		
	
| 
								 
											5 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								enum ContactUtilities {
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    static func getAllContacts() -> [String] {
							 | 
						||
| 
								 | 
							
								        var result: [String] = []
							 | 
						||
| 
								 | 
							
								        Storage.read { transaction in
							 | 
						||
| 
								 | 
							
								            TSContactThread.enumerateCollectionObjects(with: transaction) { object, _ in
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								                guard let thread = object as? TSContactThread, thread.shouldThreadBeVisible else { return }
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								                result.append(thread.contactIdentifier())
							 | 
						||
| 
								 | 
							
								            }
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        func getDisplayName(for publicKey: String) -> String {
							 | 
						||
| 
								 | 
							
								            return UserDisplayNameUtilities.getPrivateChatDisplayName(for: publicKey) ?? publicKey
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								        if let index = result.firstIndex(of: getUserHexEncodedPublicKey()) {
							 | 
						||
| 
								 | 
							
								            result.remove(at: index)
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								        return result.sorted { getDisplayName(for: $0) < getDisplayName(for: $1) }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |