Remove the reliance on a room list item and the preview api from the BannedRoomProxy
This commit is contained in:
committed by
Stefan Ceriu
parent
f6c2405427
commit
ebbe0eb646
@@ -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)")
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user