mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 11:58:32 +00:00
Bump SDK (#2261)
This commit is contained in:
@@ -217,9 +217,9 @@ class SDKClientMock: SDKClientProtocol {
|
||||
public var getMediaContentMediaSourceReceivedMediaSource: MediaSource?
|
||||
public var getMediaContentMediaSourceReceivedInvocations: [MediaSource] = []
|
||||
public var getMediaContentMediaSourceReturnValue: Data!
|
||||
public var getMediaContentMediaSourceClosure: ((MediaSource) throws -> Data)?
|
||||
public var getMediaContentMediaSourceClosure: ((MediaSource) async throws -> Data)?
|
||||
|
||||
public func getMediaContent(mediaSource: MediaSource) throws -> Data {
|
||||
public func getMediaContent(mediaSource: MediaSource) async throws -> Data {
|
||||
if let error = getMediaContentMediaSourceThrowableError {
|
||||
throw error
|
||||
}
|
||||
@@ -227,7 +227,7 @@ class SDKClientMock: SDKClientProtocol {
|
||||
getMediaContentMediaSourceReceivedMediaSource = mediaSource
|
||||
getMediaContentMediaSourceReceivedInvocations.append(mediaSource)
|
||||
if let getMediaContentMediaSourceClosure = getMediaContentMediaSourceClosure {
|
||||
return try getMediaContentMediaSourceClosure(mediaSource)
|
||||
return try await getMediaContentMediaSourceClosure(mediaSource)
|
||||
} else {
|
||||
return getMediaContentMediaSourceReturnValue
|
||||
}
|
||||
@@ -242,9 +242,9 @@ class SDKClientMock: SDKClientProtocol {
|
||||
public var getMediaFileMediaSourceBodyMimeTypeUseCacheTempDirReceivedArguments: (mediaSource: MediaSource, body: String?, mimeType: String, useCache: Bool, tempDir: String?)?
|
||||
public var getMediaFileMediaSourceBodyMimeTypeUseCacheTempDirReceivedInvocations: [(mediaSource: MediaSource, body: String?, mimeType: String, useCache: Bool, tempDir: String?)] = []
|
||||
public var getMediaFileMediaSourceBodyMimeTypeUseCacheTempDirReturnValue: MediaFileHandle!
|
||||
public var getMediaFileMediaSourceBodyMimeTypeUseCacheTempDirClosure: ((MediaSource, String?, String, Bool, String?) throws -> MediaFileHandle)?
|
||||
public var getMediaFileMediaSourceBodyMimeTypeUseCacheTempDirClosure: ((MediaSource, String?, String, Bool, String?) async throws -> MediaFileHandle)?
|
||||
|
||||
public func getMediaFile(mediaSource: MediaSource, body: String?, mimeType: String, useCache: Bool, tempDir: String?) throws -> MediaFileHandle {
|
||||
public func getMediaFile(mediaSource: MediaSource, body: String?, mimeType: String, useCache: Bool, tempDir: String?) async throws -> MediaFileHandle {
|
||||
if let error = getMediaFileMediaSourceBodyMimeTypeUseCacheTempDirThrowableError {
|
||||
throw error
|
||||
}
|
||||
@@ -252,7 +252,7 @@ class SDKClientMock: SDKClientProtocol {
|
||||
getMediaFileMediaSourceBodyMimeTypeUseCacheTempDirReceivedArguments = (mediaSource: mediaSource, body: body, mimeType: mimeType, useCache: useCache, tempDir: tempDir)
|
||||
getMediaFileMediaSourceBodyMimeTypeUseCacheTempDirReceivedInvocations.append((mediaSource: mediaSource, body: body, mimeType: mimeType, useCache: useCache, tempDir: tempDir))
|
||||
if let getMediaFileMediaSourceBodyMimeTypeUseCacheTempDirClosure = getMediaFileMediaSourceBodyMimeTypeUseCacheTempDirClosure {
|
||||
return try getMediaFileMediaSourceBodyMimeTypeUseCacheTempDirClosure(mediaSource, body, mimeType, useCache, tempDir)
|
||||
return try await getMediaFileMediaSourceBodyMimeTypeUseCacheTempDirClosure(mediaSource, body, mimeType, useCache, tempDir)
|
||||
} else {
|
||||
return getMediaFileMediaSourceBodyMimeTypeUseCacheTempDirReturnValue
|
||||
}
|
||||
@@ -267,9 +267,9 @@ class SDKClientMock: SDKClientProtocol {
|
||||
public var getMediaThumbnailMediaSourceWidthHeightReceivedArguments: (mediaSource: MediaSource, width: UInt64, height: UInt64)?
|
||||
public var getMediaThumbnailMediaSourceWidthHeightReceivedInvocations: [(mediaSource: MediaSource, width: UInt64, height: UInt64)] = []
|
||||
public var getMediaThumbnailMediaSourceWidthHeightReturnValue: Data!
|
||||
public var getMediaThumbnailMediaSourceWidthHeightClosure: ((MediaSource, UInt64, UInt64) throws -> Data)?
|
||||
public var getMediaThumbnailMediaSourceWidthHeightClosure: ((MediaSource, UInt64, UInt64) async throws -> Data)?
|
||||
|
||||
public func getMediaThumbnail(mediaSource: MediaSource, width: UInt64, height: UInt64) throws -> Data {
|
||||
public func getMediaThumbnail(mediaSource: MediaSource, width: UInt64, height: UInt64) async throws -> Data {
|
||||
if let error = getMediaThumbnailMediaSourceWidthHeightThrowableError {
|
||||
throw error
|
||||
}
|
||||
@@ -277,7 +277,7 @@ class SDKClientMock: SDKClientProtocol {
|
||||
getMediaThumbnailMediaSourceWidthHeightReceivedArguments = (mediaSource: mediaSource, width: width, height: height)
|
||||
getMediaThumbnailMediaSourceWidthHeightReceivedInvocations.append((mediaSource: mediaSource, width: width, height: height))
|
||||
if let getMediaThumbnailMediaSourceWidthHeightClosure = getMediaThumbnailMediaSourceWidthHeightClosure {
|
||||
return try getMediaThumbnailMediaSourceWidthHeightClosure(mediaSource, width, height)
|
||||
return try await getMediaThumbnailMediaSourceWidthHeightClosure(mediaSource, width, height)
|
||||
} else {
|
||||
return getMediaThumbnailMediaSourceWidthHeightReturnValue
|
||||
}
|
||||
@@ -695,9 +695,9 @@ class SDKClientMock: SDKClientProtocol {
|
||||
public var uploadMediaMimeTypeDataProgressWatcherReceivedArguments: (mimeType: String, data: Data, progressWatcher: ProgressWatcher?)?
|
||||
public var uploadMediaMimeTypeDataProgressWatcherReceivedInvocations: [(mimeType: String, data: Data, progressWatcher: ProgressWatcher?)] = []
|
||||
public var uploadMediaMimeTypeDataProgressWatcherReturnValue: String!
|
||||
public var uploadMediaMimeTypeDataProgressWatcherClosure: ((String, Data, ProgressWatcher?) throws -> String)?
|
||||
public var uploadMediaMimeTypeDataProgressWatcherClosure: ((String, Data, ProgressWatcher?) async throws -> String)?
|
||||
|
||||
public func uploadMedia(mimeType: String, data: Data, progressWatcher: ProgressWatcher?) throws -> String {
|
||||
public func uploadMedia(mimeType: String, data: Data, progressWatcher: ProgressWatcher?) async throws -> String {
|
||||
if let error = uploadMediaMimeTypeDataProgressWatcherThrowableError {
|
||||
throw error
|
||||
}
|
||||
@@ -705,7 +705,7 @@ class SDKClientMock: SDKClientProtocol {
|
||||
uploadMediaMimeTypeDataProgressWatcherReceivedArguments = (mimeType: mimeType, data: data, progressWatcher: progressWatcher)
|
||||
uploadMediaMimeTypeDataProgressWatcherReceivedInvocations.append((mimeType: mimeType, data: data, progressWatcher: progressWatcher))
|
||||
if let uploadMediaMimeTypeDataProgressWatcherClosure = uploadMediaMimeTypeDataProgressWatcherClosure {
|
||||
return try uploadMediaMimeTypeDataProgressWatcherClosure(mimeType, data, progressWatcher)
|
||||
return try await uploadMediaMimeTypeDataProgressWatcherClosure(mimeType, data, progressWatcher)
|
||||
} else {
|
||||
return uploadMediaMimeTypeDataProgressWatcherReturnValue
|
||||
}
|
||||
|
||||
@@ -266,16 +266,14 @@ class ClientProxy: ClientProxyProtocol {
|
||||
|
||||
func uploadMedia(_ media: MediaInfo) async -> Result<String, ClientProxyError> {
|
||||
guard let mimeType = media.mimeType else { return .failure(ClientProxyError.mediaFileError) }
|
||||
return await Task.dispatch(on: clientQueue) {
|
||||
do {
|
||||
let data = try Data(contentsOf: media.url)
|
||||
let matrixUrl = try self.client.uploadMedia(mimeType: mimeType, data: data, progressWatcher: nil)
|
||||
return .success(matrixUrl)
|
||||
} catch let error as ClientError {
|
||||
return .failure(ClientProxyError.failedUploadingMedia(error.code))
|
||||
} catch {
|
||||
return .failure(ClientProxyError.mediaFileError)
|
||||
}
|
||||
do {
|
||||
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 {
|
||||
return .failure(ClientProxyError.failedUploadingMedia(error.code))
|
||||
} catch {
|
||||
return .failure(ClientProxyError.mediaFileError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,27 +36,25 @@ actor MediaLoader: MediaLoaderProtocol {
|
||||
|
||||
func loadMediaContentForSource(_ source: MediaSourceProxy) async throws -> Data {
|
||||
try await enqueueLoadMediaRequest(forSource: source) {
|
||||
try self.client.getMediaContent(mediaSource: source.underlyingSource)
|
||||
try await self.client.getMediaContent(mediaSource: source.underlyingSource)
|
||||
}
|
||||
}
|
||||
|
||||
func loadMediaThumbnailForSource(_ source: MediaSourceProxy, width: UInt, height: UInt) async throws -> Data {
|
||||
try await enqueueLoadMediaRequest(forSource: source) {
|
||||
try self.client.getMediaThumbnail(mediaSource: source.underlyingSource, width: UInt64(width), height: UInt64(height))
|
||||
try await self.client.getMediaThumbnail(mediaSource: source.underlyingSource, width: UInt64(width), height: UInt64(height))
|
||||
}
|
||||
}
|
||||
|
||||
func loadMediaFileForSource(_ source: MediaSourceProxy, body: String?) async throws -> MediaFileHandleProxy {
|
||||
let result = try await Task.dispatch(on: clientQueue) {
|
||||
try self.client.getMediaFile(mediaSource: source.underlyingSource, body: body, mimeType: source.mimeType ?? "application/octet-stream", useCache: true, tempDir: nil)
|
||||
}
|
||||
let result = try await client.getMediaFile(mediaSource: source.underlyingSource, body: body, mimeType: source.mimeType ?? "application/octet-stream", useCache: true, tempDir: nil)
|
||||
|
||||
return MediaFileHandleProxy(handle: result)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func enqueueLoadMediaRequest(forSource source: MediaSourceProxy, operation: @escaping () throws -> Data) async throws -> Data {
|
||||
private func enqueueLoadMediaRequest(forSource source: MediaSourceProxy, operation: @escaping () async throws -> Data) async throws -> Data {
|
||||
if let ongoingRequest = ongoingRequests[source] {
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
ongoingRequest.continuations.append(continuation)
|
||||
@@ -71,9 +69,7 @@ actor MediaLoader: MediaLoaderProtocol {
|
||||
}
|
||||
|
||||
do {
|
||||
let result = try await Task.dispatch(on: clientQueue) {
|
||||
try operation()
|
||||
}
|
||||
let result = try await operation()
|
||||
|
||||
ongoingRequest.continuations.forEach { $0.resume(returning: result) }
|
||||
|
||||
|
||||
+8
-2
@@ -27,8 +27,14 @@ private class WeakSessionVerificationControllerProxy: SessionVerificationControl
|
||||
|
||||
// MARK: - SessionVerificationControllerDelegate
|
||||
|
||||
func didReceiveVerificationData(data: [MatrixRustSDK.SessionVerificationEmoji]) {
|
||||
proxy?.didReceiveData(data)
|
||||
func didReceiveVerificationData(data: MatrixRustSDK.SessionVerificationData) {
|
||||
switch data {
|
||||
// We can handle only emojis for now
|
||||
case .emojis(let emojis, _):
|
||||
proxy?.didReceiveData(emojis)
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
func didAcceptVerificationRequest() {
|
||||
|
||||
@@ -387,7 +387,7 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
|
||||
return await Task.dispatch(on: lowPriorityDispatchQueue) {
|
||||
do {
|
||||
try self.timeline.sendReadReceipt(eventId: eventID)
|
||||
try self.timeline.sendReadReceipt(receiptType: .read, eventId: eventID)
|
||||
return .success(())
|
||||
} catch {
|
||||
return .failure(.failedSendingReadReceipt)
|
||||
|
||||
Reference in New Issue
Block a user