mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Apply the logic from the previous commit and the JoinRoomProxy to the KnockedRoomProxy
This commit is contained in:
committed by
Stefan Ceriu
parent
ae42540ec0
commit
54a4656469
@@ -915,12 +915,16 @@ class ClientProxy: ClientProxyProtocol {
|
||||
|
||||
return try await .invited(InvitedRoomProxy(room: room))
|
||||
case .knocked:
|
||||
if appSettings.knockingEnabled {
|
||||
return try await .knocked(KnockedRoomProxy(roomListItem: roomListItem,
|
||||
roomPreview: roomListItem.previewRoom(via: []),
|
||||
ownUserID: userID))
|
||||
guard appSettings.knockingEnabled else {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
|
||||
guard let room = try client.getRoom(roomId: roomID) else {
|
||||
MXLog.error("Could not find room with ID: \(roomID)")
|
||||
return nil
|
||||
}
|
||||
|
||||
return try await .knocked(KnockedRoomProxy(room: room))
|
||||
case .joined:
|
||||
guard let room = try client.getRoom(roomId: roomID) else {
|
||||
MXLog.error("Could not find room with ID: \(roomID)")
|
||||
|
||||
@@ -9,31 +9,24 @@ import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
class KnockedRoomProxy: KnockedRoomProxyProtocol {
|
||||
private let roomListItem: RoomListItemProtocol
|
||||
private let roomPreview: RoomPreviewProtocol
|
||||
private let room: Room
|
||||
|
||||
// A room identifier is constant and lazy stops it from being fetched
|
||||
// multiple times over FFI
|
||||
lazy var id = info.id
|
||||
|
||||
let ownUserID: String
|
||||
lazy var id: String = room.id()
|
||||
lazy var ownUserID: String = room.ownUserId()
|
||||
|
||||
let info: BaseRoomInfoProxyProtocol
|
||||
|
||||
init(roomListItem: RoomListItemProtocol,
|
||||
roomPreview: RoomPreviewProtocol,
|
||||
ownUserID: String) throws {
|
||||
self.roomListItem = roomListItem
|
||||
self.roomPreview = roomPreview
|
||||
self.ownUserID = ownUserID
|
||||
info = try RoomPreviewInfoProxy(roomPreviewInfo: roomPreview.info())
|
||||
init(room: Room) async throws {
|
||||
self.room = room
|
||||
|
||||
info = try await RoomInfoProxy(roomInfo: room.roomInfo())
|
||||
}
|
||||
|
||||
func cancelKnock() async -> Result<Void, RoomProxyError> {
|
||||
do {
|
||||
return try await .success(roomPreview.leave())
|
||||
return try await .success(room.leave())
|
||||
} catch {
|
||||
MXLog.error("Failed cancelling the knock with error: \(error)")
|
||||
MXLog.error("Failed rejecting invitiation with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user