mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
updated the SDK (#3737)
This commit is contained in:
@@ -236,9 +236,9 @@ class CreateRoomViewModel: CreateRoomViewModelType, CreateRoomViewModelProtocol
|
||||
avatarURL = URL(string: url)
|
||||
case .failure(let error):
|
||||
switch error {
|
||||
case .failedUploadingMedia(_, let errorCode):
|
||||
switch errorCode {
|
||||
case .fileTooLarge:
|
||||
case .failedUploadingMedia(let errorKind):
|
||||
switch errorKind {
|
||||
case .tooLarge:
|
||||
state.bindings.alertInfo = AlertInfo(id: .fileTooLarge)
|
||||
default:
|
||||
state.bindings.alertInfo = AlertInfo(id: .failedUploadingMedia)
|
||||
|
||||
@@ -131,12 +131,9 @@ class AuthenticationService: AuthenticationServiceProtocol {
|
||||
}
|
||||
|
||||
return await userSession(for: client)
|
||||
} catch {
|
||||
MXLog.error("Failed logging in with error: \(error)")
|
||||
// FIXME: How about we make a proper type in the FFI? 😅
|
||||
guard let error = error as? ClientError else { return .failure(.failedLoggingIn) }
|
||||
|
||||
switch error.code {
|
||||
} catch let ClientError.MatrixApi(errorKind, _, _) {
|
||||
MXLog.error("Failed logging in with error kind: \(errorKind)")
|
||||
switch errorKind {
|
||||
case .forbidden:
|
||||
return .failure(.invalidCredentials)
|
||||
case .userDeactivated:
|
||||
@@ -144,6 +141,9 @@ class AuthenticationService: AuthenticationServiceProtocol {
|
||||
default:
|
||||
return .failure(.failedLoggingIn)
|
||||
}
|
||||
} catch {
|
||||
MXLog.error("Failed logging in with error: \(error)")
|
||||
return .failure(.failedLoggingIn)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
//
|
||||
// Copyright 2022-2024 New Vector Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
enum MatrixErrorCode: String, CaseIterable {
|
||||
case unknown = "M_UNKNOWN"
|
||||
case userDeactivated = "M_USER_DEACTIVATED"
|
||||
case forbidden = "M_FORBIDDEN"
|
||||
case fileTooLarge = "M_TOO_LARGE"
|
||||
}
|
||||
|
||||
extension ClientError {
|
||||
var code: MatrixErrorCode {
|
||||
guard case let .Generic(message) = self else { return .unknown }
|
||||
|
||||
guard let first = MatrixErrorCode.allCases.first(where: { message.contains($0.rawValue) }) else {
|
||||
return .unknown
|
||||
}
|
||||
|
||||
return first
|
||||
}
|
||||
}
|
||||
@@ -465,9 +465,9 @@ class ClientProxy: ClientProxyProtocol {
|
||||
let data = try Data(contentsOf: media.url)
|
||||
let matrixUrl = try await client.uploadMedia(mimeType: mimeType, data: data, progressWatcher: nil)
|
||||
return .success(matrixUrl)
|
||||
} catch let error as ClientError {
|
||||
MXLog.error("Failed uploading media with error: \(error)")
|
||||
return .failure(ClientProxyError.failedUploadingMedia(error, error.code))
|
||||
} catch let ClientError.MatrixApi(errorKind, _, _) {
|
||||
MXLog.error("Failed uploading media with error kind: \(errorKind)")
|
||||
return .failure(ClientProxyError.failedUploadingMedia(errorKind))
|
||||
} catch {
|
||||
MXLog.error("Failed uploading media with error: \(error)")
|
||||
return .failure(ClientProxyError.sdkError(error))
|
||||
@@ -503,7 +503,8 @@ class ClientProxy: ClientProxyProtocol {
|
||||
do {
|
||||
let roomPreview = try await client.getRoomPreviewFromRoomId(roomId: identifier, viaServers: via)
|
||||
return try .success(RoomPreviewProxy(roomPreview: roomPreview))
|
||||
} catch let error as ClientError where error.code == .forbidden {
|
||||
} catch ClientError.MatrixApi(.forbidden, _, _) {
|
||||
MXLog.error("Failed retrieving preview for room: \(identifier) is private")
|
||||
return .failure(.roomPreviewIsPrivate)
|
||||
} catch {
|
||||
MXLog.error("Failed retrieving preview for room: \(identifier) with error: \(error)")
|
||||
|
||||
@@ -33,7 +33,7 @@ enum ClientProxyError: Error {
|
||||
|
||||
case invalidMedia
|
||||
case invalidServerName
|
||||
case failedUploadingMedia(Error, MatrixErrorCode)
|
||||
case failedUploadingMedia(ErrorKind)
|
||||
case roomPreviewIsPrivate
|
||||
case failedRetrievingUserIdentity
|
||||
case failedResolvingRoomAlias
|
||||
|
||||
Reference in New Issue
Block a user