From ebbe0eb646ecafa32cc2c9466880ae6d9cf5c3e7 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Mon, 26 May 2025 10:10:48 +0300 Subject: [PATCH] Remove the reliance on a room list item and the preview api from the BannedRoomProxy --- .../Sources/Services/Client/ClientProxy.swift | 4 +--- .../Services/Room/BannedRoomProxy.swift | 23 +++++++------------ 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/ElementX/Sources/Services/Client/ClientProxy.swift b/ElementX/Sources/Services/Client/ClientProxy.swift index 92be110e9..edae37d8e 100644 --- a/ElementX/Sources/Services/Client/ClientProxy.swift +++ b/ElementX/Sources/Services/Client/ClientProxy.swift @@ -938,9 +938,7 @@ class ClientProxy: ClientProxyProtocol { case .left: return .left case .banned: - return try await .banned(BannedRoomProxy(roomListItem: roomListItem, - roomPreview: roomListItem.previewRoom(via: []), - ownUserID: userID)) + return try await .banned(BannedRoomProxy(room: room)) } } catch { MXLog.error("Failed retrieving room: \(roomID), with error: \(error)") diff --git a/ElementX/Sources/Services/Room/BannedRoomProxy.swift b/ElementX/Sources/Services/Room/BannedRoomProxy.swift index 0dbf83ff9..a394fca85 100644 --- a/ElementX/Sources/Services/Room/BannedRoomProxy.swift +++ b/ElementX/Sources/Services/Room/BannedRoomProxy.swift @@ -9,29 +9,22 @@ import Foundation import MatrixRustSDK class BannedRoomProxy: BannedRoomProxyProtocol { - 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 = room.id() + lazy var ownUserID = 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 forgetRoom() async -> Result { do { - return try await .success(roomPreview.forget()) + return try await .success(room.forget()) } catch { MXLog.error("Failed forgetting the room with error: \(error)") return .failure(.sdkError(error))