mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
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:
committed by
Stefan Ceriu
parent
29cfcb0b85
commit
a7c4a32285
@@ -1,4 +1,4 @@
|
|||||||
// Generated using Sourcery 2.2.6 — https://github.com/krzysztofzablocki/Sourcery
|
// Generated using Sourcery 2.2.7 — https://github.com/krzysztofzablocki/Sourcery
|
||||||
// DO NOT EDIT
|
// DO NOT EDIT
|
||||||
|
|
||||||
// swiftlint:disable all
|
// swiftlint:disable all
|
||||||
@@ -13286,6 +13286,75 @@ open class RoomSDKMock: MatrixRustSDK.Room, @unchecked Sendable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//MARK: - inviter
|
||||||
|
|
||||||
|
open var inviterThrowableError: Error?
|
||||||
|
var inviterUnderlyingCallsCount = 0
|
||||||
|
open var inviterCallsCount: Int {
|
||||||
|
get {
|
||||||
|
if Thread.isMainThread {
|
||||||
|
return inviterUnderlyingCallsCount
|
||||||
|
} else {
|
||||||
|
var returnValue: Int? = nil
|
||||||
|
DispatchQueue.main.sync {
|
||||||
|
returnValue = inviterUnderlyingCallsCount
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnValue!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
if Thread.isMainThread {
|
||||||
|
inviterUnderlyingCallsCount = newValue
|
||||||
|
} else {
|
||||||
|
DispatchQueue.main.sync {
|
||||||
|
inviterUnderlyingCallsCount = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
open var inviterCalled: Bool {
|
||||||
|
return inviterCallsCount > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
var inviterUnderlyingReturnValue: RoomMember?
|
||||||
|
open var inviterReturnValue: RoomMember? {
|
||||||
|
get {
|
||||||
|
if Thread.isMainThread {
|
||||||
|
return inviterUnderlyingReturnValue
|
||||||
|
} else {
|
||||||
|
var returnValue: RoomMember?? = nil
|
||||||
|
DispatchQueue.main.sync {
|
||||||
|
returnValue = inviterUnderlyingReturnValue
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnValue!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
if Thread.isMainThread {
|
||||||
|
inviterUnderlyingReturnValue = newValue
|
||||||
|
} else {
|
||||||
|
DispatchQueue.main.sync {
|
||||||
|
inviterUnderlyingReturnValue = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
open var inviterClosure: (() async throws -> RoomMember?)?
|
||||||
|
|
||||||
|
open override func inviter() async throws -> RoomMember? {
|
||||||
|
if let error = inviterThrowableError {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
inviterCallsCount += 1
|
||||||
|
if let inviterClosure = inviterClosure {
|
||||||
|
return try await inviterClosure()
|
||||||
|
} else {
|
||||||
|
return inviterReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//MARK: - isDirect
|
//MARK: - isDirect
|
||||||
|
|
||||||
var isDirectUnderlyingCallsCount = 0
|
var isDirectUnderlyingCallsCount = 0
|
||||||
|
|||||||
@@ -908,9 +908,12 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
|
|
||||||
switch roomListItem.membership() {
|
switch roomListItem.membership() {
|
||||||
case .invited:
|
case .invited:
|
||||||
return try await .invited(InvitedRoomProxy(roomListItem: roomListItem,
|
guard let room = try client.getRoom(roomId: roomID) else {
|
||||||
roomPreview: roomListItem.previewRoom(via: []),
|
MXLog.error("Could not find room with ID: \(roomID)")
|
||||||
ownUserID: userID))
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return try await .invited(InvitedRoomProxy(room: room))
|
||||||
case .knocked:
|
case .knocked:
|
||||||
if appSettings.knockingEnabled {
|
if appSettings.knockingEnabled {
|
||||||
return try await .knocked(KnockedRoomProxy(roomListItem: roomListItem,
|
return try await .knocked(KnockedRoomProxy(roomListItem: roomListItem,
|
||||||
|
|||||||
@@ -10,31 +10,25 @@ import MatrixRustSDK
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
class InvitedRoomProxy: InvitedRoomProxyProtocol {
|
class InvitedRoomProxy: InvitedRoomProxyProtocol {
|
||||||
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: String = room.id()
|
||||||
// multiple times over FFI
|
lazy var ownUserID: String = room.ownUserId()
|
||||||
lazy var id: String = info.id
|
|
||||||
|
|
||||||
let ownUserID: String
|
|
||||||
|
|
||||||
let info: BaseRoomInfoProxyProtocol
|
let info: BaseRoomInfoProxyProtocol
|
||||||
let inviter: RoomMemberProxyProtocol?
|
let inviter: RoomMemberProxyProtocol?
|
||||||
|
|
||||||
init(roomListItem: RoomListItemProtocol,
|
init(room: Room) async throws {
|
||||||
roomPreview: RoomPreviewProtocol,
|
self.room = room
|
||||||
ownUserID: String) async throws {
|
|
||||||
self.roomListItem = roomListItem
|
info = try await RoomInfoProxy(roomInfo: room.roomInfo())
|
||||||
self.roomPreview = roomPreview
|
|
||||||
self.ownUserID = ownUserID
|
inviter = try? await room.inviter().map(RoomMemberProxy.init)
|
||||||
info = try RoomPreviewInfoProxy(roomPreviewInfo: roomPreview.info())
|
|
||||||
inviter = await roomPreview.inviter().map(RoomMemberProxy.init)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func rejectInvitation() async -> Result<Void, RoomProxyError> {
|
func rejectInvitation() async -> Result<Void, RoomProxyError> {
|
||||||
do {
|
do {
|
||||||
return try await .success(roomPreview.leave())
|
return try await .success(room.leave())
|
||||||
} catch {
|
} catch {
|
||||||
MXLog.error("Failed rejecting invitiation with error: \(error)")
|
MXLog.error("Failed rejecting invitiation with error: \(error)")
|
||||||
return .failure(.sdkError(error))
|
return .failure(.sdkError(error))
|
||||||
|
|||||||
Reference in New Issue
Block a user