mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Fix various new SDK breaking changes.
This commit is contained in:
committed by
Stefan Ceriu
parent
ffe2f726e7
commit
bd49500fa1
@@ -3309,8 +3309,8 @@ class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
|
|||||||
var reportRoomForIdentifierReasonCalled: Bool {
|
var reportRoomForIdentifierReasonCalled: Bool {
|
||||||
return reportRoomForIdentifierReasonCallsCount > 0
|
return reportRoomForIdentifierReasonCallsCount > 0
|
||||||
}
|
}
|
||||||
var reportRoomForIdentifierReasonReceivedArguments: (identifier: String, reason: String?)?
|
var reportRoomForIdentifierReasonReceivedArguments: (identifier: String, reason: String)?
|
||||||
var reportRoomForIdentifierReasonReceivedInvocations: [(identifier: String, reason: String?)] = []
|
var reportRoomForIdentifierReasonReceivedInvocations: [(identifier: String, reason: String)] = []
|
||||||
|
|
||||||
var reportRoomForIdentifierReasonUnderlyingReturnValue: Result<Void, ClientProxyError>!
|
var reportRoomForIdentifierReasonUnderlyingReturnValue: Result<Void, ClientProxyError>!
|
||||||
var reportRoomForIdentifierReasonReturnValue: Result<Void, ClientProxyError>! {
|
var reportRoomForIdentifierReasonReturnValue: Result<Void, ClientProxyError>! {
|
||||||
@@ -3336,9 +3336,9 @@ class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var reportRoomForIdentifierReasonClosure: ((String, String?) async -> Result<Void, ClientProxyError>)?
|
var reportRoomForIdentifierReasonClosure: ((String, String) async -> Result<Void, ClientProxyError>)?
|
||||||
|
|
||||||
func reportRoomForIdentifier(_ identifier: String, reason: String?) async -> Result<Void, ClientProxyError> {
|
func reportRoomForIdentifier(_ identifier: String, reason: String) async -> Result<Void, ClientProxyError> {
|
||||||
reportRoomForIdentifierReasonCallsCount += 1
|
reportRoomForIdentifierReasonCallsCount += 1
|
||||||
reportRoomForIdentifierReasonReceivedArguments = (identifier: identifier, reason: reason)
|
reportRoomForIdentifierReasonReceivedArguments = (identifier: identifier, reason: reason)
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
@@ -6946,7 +6946,7 @@ class JoinedRoomProxyMock: JoinedRoomProxyProtocol, @unchecked Sendable {
|
|||||||
return reportRoomReasonCallsCount > 0
|
return reportRoomReasonCallsCount > 0
|
||||||
}
|
}
|
||||||
var reportRoomReasonReceivedReason: String?
|
var reportRoomReasonReceivedReason: String?
|
||||||
var reportRoomReasonReceivedInvocations: [String?] = []
|
var reportRoomReasonReceivedInvocations: [String] = []
|
||||||
|
|
||||||
var reportRoomReasonUnderlyingReturnValue: Result<Void, RoomProxyError>!
|
var reportRoomReasonUnderlyingReturnValue: Result<Void, RoomProxyError>!
|
||||||
var reportRoomReasonReturnValue: Result<Void, RoomProxyError>! {
|
var reportRoomReasonReturnValue: Result<Void, RoomProxyError>! {
|
||||||
@@ -6972,9 +6972,9 @@ class JoinedRoomProxyMock: JoinedRoomProxyProtocol, @unchecked Sendable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var reportRoomReasonClosure: ((String?) async -> Result<Void, RoomProxyError>)?
|
var reportRoomReasonClosure: ((String) async -> Result<Void, RoomProxyError>)?
|
||||||
|
|
||||||
func reportRoom(reason: String?) async -> Result<Void, RoomProxyError> {
|
func reportRoom(reason: String) async -> Result<Void, RoomProxyError> {
|
||||||
reportRoomReasonCallsCount += 1
|
reportRoomReasonCallsCount += 1
|
||||||
reportRoomReasonReceivedReason = reason
|
reportRoomReasonReceivedReason = reason
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
|||||||
@@ -15153,10 +15153,10 @@ open class RoomSDKMock: MatrixRustSDK.Room, @unchecked Sendable {
|
|||||||
return reportRoomReasonCallsCount > 0
|
return reportRoomReasonCallsCount > 0
|
||||||
}
|
}
|
||||||
open var reportRoomReasonReceivedReason: String?
|
open var reportRoomReasonReceivedReason: String?
|
||||||
open var reportRoomReasonReceivedInvocations: [String?] = []
|
open var reportRoomReasonReceivedInvocations: [String] = []
|
||||||
open var reportRoomReasonClosure: ((String?) async throws -> Void)?
|
open var reportRoomReasonClosure: ((String) async throws -> Void)?
|
||||||
|
|
||||||
open override func reportRoom(reason: String?) async throws {
|
open override func reportRoom(reason: String) async throws {
|
||||||
if let error = reportRoomReasonThrowableError {
|
if let error = reportRoomReasonThrowableError {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
@@ -19941,7 +19941,6 @@ open class RoomPreviewSDKMock: MatrixRustSDK.RoomPreview, @unchecked Sendable {
|
|||||||
|
|
||||||
//MARK: - info
|
//MARK: - info
|
||||||
|
|
||||||
open var infoThrowableError: Error?
|
|
||||||
var infoUnderlyingCallsCount = 0
|
var infoUnderlyingCallsCount = 0
|
||||||
open var infoCallsCount: Int {
|
open var infoCallsCount: Int {
|
||||||
get {
|
get {
|
||||||
@@ -19994,15 +19993,12 @@ open class RoomPreviewSDKMock: MatrixRustSDK.RoomPreview, @unchecked Sendable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
open var infoClosure: (() throws -> RoomPreviewInfo)?
|
open var infoClosure: (() -> RoomPreviewInfo)?
|
||||||
|
|
||||||
open override func info() throws -> RoomPreviewInfo {
|
open override func info() -> RoomPreviewInfo {
|
||||||
if let error = infoThrowableError {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
infoCallsCount += 1
|
infoCallsCount += 1
|
||||||
if let infoClosure = infoClosure {
|
if let infoClosure = infoClosure {
|
||||||
return try infoClosure()
|
return infoClosure()
|
||||||
} else {
|
} else {
|
||||||
return infoReturnValue
|
return infoReturnValue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class DeclineAndBlockScreenViewModel: DeclineAndBlockScreenViewModelType, Declin
|
|||||||
case .success:
|
case .success:
|
||||||
var shouldShowFailure = false
|
var shouldShowFailure = false
|
||||||
if state.bindings.shouldReport {
|
if state.bindings.shouldReport {
|
||||||
shouldShowFailure = await clientProxy.reportRoomForIdentifier(roomID, reason: state.bindings.reportReason.isEmpty ? nil : state.bindings.reportReason).isFailure
|
shouldShowFailure = await clientProxy.reportRoomForIdentifier(roomID, reason: state.bindings.reportReason.isEmpty ? "" : state.bindings.reportReason).isFailure
|
||||||
}
|
}
|
||||||
|
|
||||||
if state.bindings.shouldBlockUser {
|
if state.bindings.shouldBlockUser {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class ReportRoomScreenViewModel: ReportRoomScreenViewModelType, ReportRoomScreen
|
|||||||
|
|
||||||
private func report() async {
|
private func report() async {
|
||||||
showLoadingIndicator()
|
showLoadingIndicator()
|
||||||
let result = await roomProxy.reportRoom(reason: state.bindings.reason.isEmpty ? nil : state.bindings.reason)
|
let result = await roomProxy.reportRoom(reason: state.bindings.reason.isEmpty ? "" : state.bindings.reason)
|
||||||
|
|
||||||
switch result {
|
switch result {
|
||||||
case .success:
|
case .success:
|
||||||
|
|||||||
@@ -572,7 +572,7 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
func roomPreviewForIdentifier(_ identifier: String, via: [String]) async -> Result<RoomPreviewProxyProtocol, ClientProxyError> {
|
func roomPreviewForIdentifier(_ identifier: String, via: [String]) async -> Result<RoomPreviewProxyProtocol, ClientProxyError> {
|
||||||
do {
|
do {
|
||||||
let roomPreview = try await client.getRoomPreviewFromRoomId(roomId: identifier, viaServers: via)
|
let roomPreview = try await client.getRoomPreviewFromRoomId(roomId: identifier, viaServers: via)
|
||||||
return try .success(RoomPreviewProxy(roomPreview: roomPreview))
|
return .success(RoomPreviewProxy(roomPreview: roomPreview))
|
||||||
} catch ClientError.MatrixApi(.forbidden, _, _, _) {
|
} catch ClientError.MatrixApi(.forbidden, _, _, _) {
|
||||||
MXLog.error("Failed retrieving preview for room: \(identifier) is private")
|
MXLog.error("Failed retrieving preview for room: \(identifier) is private")
|
||||||
return .failure(.roomPreviewIsPrivate)
|
return .failure(.roomPreviewIsPrivate)
|
||||||
@@ -590,7 +590,7 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
staticRoomSummaryProvider.roomListPublisher.value.first { $0.canonicalAlias == alias || $0.alternativeAliases.contains(alias) }
|
staticRoomSummaryProvider.roomListPublisher.value.first { $0.canonicalAlias == alias || $0.alternativeAliases.contains(alias) }
|
||||||
}
|
}
|
||||||
|
|
||||||
func reportRoomForIdentifier(_ identifier: String, reason: String?) async -> Result<Void, ClientProxyError> {
|
func reportRoomForIdentifier(_ identifier: String, reason: String) async -> Result<Void, ClientProxyError> {
|
||||||
do {
|
do {
|
||||||
guard let room = try client.getRoom(roomId: identifier) else {
|
guard let room = try client.getRoom(roomId: identifier) else {
|
||||||
MXLog.error("Failed reporting room with identifier: \(identifier), room not in local store")
|
MXLog.error("Failed reporting room with identifier: \(identifier), room not in local store")
|
||||||
@@ -1231,6 +1231,8 @@ private extension MediaPreviewConfig {
|
|||||||
.privateOnly
|
.privateOnly
|
||||||
case .off:
|
case .off:
|
||||||
.never
|
.never
|
||||||
|
case .none:
|
||||||
|
.always
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1240,6 +1242,8 @@ private extension MediaPreviewConfig {
|
|||||||
true
|
true
|
||||||
case .on:
|
case .on:
|
||||||
false
|
false
|
||||||
|
case .none:
|
||||||
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol {
|
|||||||
func roomSummaryForAlias(_ alias: String) -> RoomSummary?
|
func roomSummaryForAlias(_ alias: String) -> RoomSummary?
|
||||||
|
|
||||||
/// Will only work for rooms that are in our room list/local store
|
/// Will only work for rooms that are in our room list/local store
|
||||||
func reportRoomForIdentifier(_ identifier: String, reason: String?) async -> Result<Void, ClientProxyError>
|
func reportRoomForIdentifier(_ identifier: String, reason: String) async -> Result<Void, ClientProxyError>
|
||||||
|
|
||||||
@discardableResult func loadUserDisplayName() async -> Result<Void, ClientProxyError>
|
@discardableResult func loadUserDisplayName() async -> Result<Void, ClientProxyError>
|
||||||
|
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func reportRoom(reason: String?) async -> Result<Void, RoomProxyError> {
|
func reportRoom(reason: String) async -> Result<Void, RoomProxyError> {
|
||||||
do {
|
do {
|
||||||
try await room.reportRoom(reason: reason)
|
try await room.reportRoom(reason: reason)
|
||||||
return .success(())
|
return .success(())
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ final class RoomPreviewProxy: RoomPreviewProxyProtocol {
|
|||||||
|
|
||||||
let info: RoomPreviewInfoProxy
|
let info: RoomPreviewInfoProxy
|
||||||
|
|
||||||
init(roomPreview: RoomPreview) throws {
|
init(roomPreview: RoomPreview) {
|
||||||
self.roomPreview = roomPreview
|
self.roomPreview = roomPreview
|
||||||
info = try .init(roomPreviewInfo: roomPreview.info())
|
info = .init(roomPreviewInfo: roomPreview.info())
|
||||||
}
|
}
|
||||||
|
|
||||||
var ownMembershipDetails: RoomMembershipDetailsProxyProtocol? {
|
var ownMembershipDetails: RoomMembershipDetailsProxyProtocol? {
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ protocol JoinedRoomProxyProtocol: RoomProxyProtocol {
|
|||||||
|
|
||||||
func reportContent(_ eventID: String, reason: String?) async -> Result<Void, RoomProxyError>
|
func reportContent(_ eventID: String, reason: String?) async -> Result<Void, RoomProxyError>
|
||||||
|
|
||||||
func reportRoom(reason: String?) async -> Result<Void, RoomProxyError>
|
func reportRoom(reason: String) async -> Result<Void, RoomProxyError>
|
||||||
|
|
||||||
func leaveRoom() async -> Result<Void, RoomProxyError>
|
func leaveRoom() async -> Result<Void, RoomProxyError>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user