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:
@@ -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