Pass the full room into the invited room proxy and stop automatically retrieving the preview

- this will help speed up leaving invites but also stop fetching previews twice in the join room screen
This commit is contained in:
Stefan Ceriu
2025-05-23 11:59:38 +03:00
committed by Stefan Ceriu
parent 29cfcb0b85
commit a7c4a32285
3 changed files with 86 additions and 20 deletions
@@ -10,31 +10,25 @@ import MatrixRustSDK
import UIKit
class InvitedRoomProxy: InvitedRoomProxyProtocol {
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: String = info.id
let ownUserID: String
lazy var id: String = room.id()
lazy var ownUserID: String = room.ownUserId()
let info: BaseRoomInfoProxyProtocol
let inviter: RoomMemberProxyProtocol?
init(room: Room) async throws {
self.room = room
init(roomListItem: RoomListItemProtocol,
roomPreview: RoomPreviewProtocol,
ownUserID: String) async throws {
self.roomListItem = roomListItem
self.roomPreview = roomPreview
self.ownUserID = ownUserID
info = try RoomPreviewInfoProxy(roomPreviewInfo: roomPreview.info())
inviter = await roomPreview.inviter().map(RoomMemberProxy.init)
info = try await RoomInfoProxy(roomInfo: room.roomInfo())
inviter = try? await room.inviter().map(RoomMemberProxy.init)
}
func rejectInvitation() async -> Result<Void, RoomProxyError> {
do {
return try await .success(roomPreview.leave())
return try await .success(room.leave())
} catch {
MXLog.error("Failed rejecting invitiation with error: \(error)")
return .failure(.sdkError(error))