mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Show or create direct message room (#716)
* add start chat flow with UI * add feature flag for start chat * add changelog * fix naming and tests * fix empty display name in user cell * Update ElementX/Sources/Application/AppSettings.swift Co-authored-by: Alfonso Grillo <alfogrillo@element.io> * add screenshots from UI test * fix swiftFormat and add identifiers * fix warnings * add the create or open already existing direct room feature * add changelog * add UserProfile object, add loading indicator in start chat flow * fix test * add new section for user profile in start chat * fix duplicates input on search bar * Update ElementX/Sources/Services/Client/ClientProxy.swift Co-authored-by: Alfonso Grillo <alfogrillo@element.io> * Update ElementX/Sources/Services/Client/ClientProxy.swift Co-authored-by: Alfonso Grillo <alfogrillo@element.io> --------- Co-authored-by: Alfonso Grillo <alfogrillo@element.io>
This commit is contained in:
@@ -143,6 +143,29 @@ class ClientProxy: ClientProxyProtocol {
|
||||
slidingSyncObserverToken = nil
|
||||
}
|
||||
|
||||
func directRoomForUserID(_ userID: String) async -> Result<String?, ClientProxyError> {
|
||||
await Task.dispatch(on: clientQueue) {
|
||||
do {
|
||||
let roomId = try self.client.getDmRoom(userId: userID)?.id()
|
||||
return .success(roomId)
|
||||
} catch {
|
||||
return .failure(.failedRetrievingDirectRoom)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func createDirectRoom(with userID: String) async -> Result<String, ClientProxyError> {
|
||||
await Task.dispatch(on: clientQueue) {
|
||||
do {
|
||||
let parameters = CreateRoomParameters(name: "", topic: nil, isEncrypted: true, isDirect: true, visibility: .private, preset: .trustedPrivateChat, invite: [userID], avatar: nil)
|
||||
let result = try self.client.createRoom(request: parameters)
|
||||
return .success(result)
|
||||
} catch {
|
||||
return .failure(.failedCreatingRoom)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func roomForIdentifier(_ identifier: String) async -> RoomProxyProtocol? {
|
||||
let (slidingSyncRoom, room) = await Task.dispatch(on: clientQueue) {
|
||||
self.roomTupleForIdentifier(identifier)
|
||||
|
||||
Reference in New Issue
Block a user