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
@@ -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<Void, RoomProxyError> {
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))