mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
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
154c44b701
commit
ccf437f5fb
@@ -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))
|
||||||
|
|||||||
Reference in New Issue
Block a user