mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-07 21:08:28 +00:00
7c75498b4d
* Store RoomInfo updates in JoinedRoomProxy and read from them directly. * Remove all RoomProxy properties that were reading from the RoomInfo.
50 lines
1.4 KiB
Swift
50 lines
1.4 KiB
Swift
//
|
|
// Copyright 2024 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
// Please see LICENSE in the repository root for full details.
|
|
//
|
|
|
|
import Foundation
|
|
import MatrixRustSDK
|
|
import UIKit
|
|
|
|
class InvitedRoomProxy: InvitedRoomProxyProtocol {
|
|
private let roomListItem: RoomListItemProtocol
|
|
private let room: RoomProtocol
|
|
|
|
// A room identifier is constant and lazy stops it from being fetched
|
|
// multiple times over FFI
|
|
lazy var id: String = room.id()
|
|
|
|
var ownUserID: String { room.ownUserId() }
|
|
|
|
let info: RoomInfoProxy
|
|
|
|
init(roomListItem: RoomListItemProtocol,
|
|
room: RoomProtocol) async throws {
|
|
self.roomListItem = roomListItem
|
|
self.room = room
|
|
info = try await RoomInfoProxy(roomInfo: room.roomInfo())
|
|
}
|
|
|
|
func acceptInvitation() async -> Result<Void, RoomProxyError> {
|
|
do {
|
|
try await room.join()
|
|
return .success(())
|
|
} catch {
|
|
MXLog.error("Failed accepting invitation with error: \(error)")
|
|
return .failure(.sdkError(error))
|
|
}
|
|
}
|
|
|
|
func rejectInvitation() async -> Result<Void, RoomProxyError> {
|
|
do {
|
|
return try await .success(room.leave())
|
|
} catch {
|
|
MXLog.error("Failed rejecting invitiation with error: \(error)")
|
|
return .failure(.sdkError(error))
|
|
}
|
|
}
|
|
}
|