Remove the reliance on a room list item and the preview api from the BannedRoomProxy

This commit is contained in:
Stefan Ceriu
2025-05-26 10:10:48 +03:00
committed by Stefan Ceriu
parent 154c44b701
commit ccf437f5fb
2 changed files with 9 additions and 18 deletions
@@ -938,9 +938,7 @@ class ClientProxy: ClientProxyProtocol {
case .left: case .left:
return .left return .left
case .banned: case .banned:
return try await .banned(BannedRoomProxy(roomListItem: roomListItem, return try await .banned(BannedRoomProxy(room: room))
roomPreview: roomListItem.previewRoom(via: []),
ownUserID: userID))
} }
} catch { } catch {
MXLog.error("Failed retrieving room: \(roomID), with error: \(error)") MXLog.error("Failed retrieving room: \(roomID), with error: \(error)")
@@ -9,29 +9,22 @@ import Foundation
import MatrixRustSDK import MatrixRustSDK
class BannedRoomProxy: BannedRoomProxyProtocol { class BannedRoomProxy: BannedRoomProxyProtocol {
private let roomListItem: RoomListItemProtocol private let room: Room
private let roomPreview: RoomPreviewProtocol
// A room identifier is constant and lazy stops it from being fetched lazy var id = room.id()
// multiple times over FFI lazy var ownUserID = room.ownUserId()
lazy var id = info.id
let ownUserID: String
let info: BaseRoomInfoProxyProtocol let info: BaseRoomInfoProxyProtocol
init(roomListItem: RoomListItemProtocol, init(room: Room) async throws {
roomPreview: RoomPreviewProtocol, self.room = room
ownUserID: String) throws {
self.roomListItem = roomListItem info = try await RoomInfoProxy(roomInfo: room.roomInfo())
self.roomPreview = roomPreview
self.ownUserID = ownUserID
info = try RoomPreviewInfoProxy(roomPreviewInfo: roomPreview.info())
} }
func forgetRoom() async -> Result<Void, RoomProxyError> { func forgetRoom() async -> Result<Void, RoomProxyError> {
do { do {
return try await .success(roomPreview.forget()) return try await .success(room.forget())
} catch { } catch {
MXLog.error("Failed forgetting the room with error: \(error)") MXLog.error("Failed forgetting the room with error: \(error)")
return .failure(.sdkError(error)) return .failure(.sdkError(error))