Bump the RustSDK to v1.0.79-alpha

This commit is contained in:
Stefan Ceriu
2023-06-21 19:00:52 +03:00
committed by Mauro
parent 6d5652d56a
commit bbcfec3574
8 changed files with 46 additions and 40 deletions
+1 -1
View File
@@ -5008,7 +5008,7 @@
repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift"; repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift";
requirement = { requirement = {
kind = exactVersion; kind = exactVersion;
version = "1.0.78-alpha"; version = "1.0.79-alpha";
}; };
}; };
96495DD8554E2F39D3954354 /* XCRemoteSwiftPackageReference "posthog-ios" */ = { 96495DD8554E2F39D3954354 /* XCRemoteSwiftPackageReference "posthog-ios" */ = {
@@ -11,7 +11,7 @@
{ {
"identity" : "compound-ios", "identity" : "compound-ios",
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://github.com/vector-im/compound-ios.git", "location" : "https://github.com/vector-im/compound-ios",
"state" : { "state" : {
"revision" : "e8b35fdd8c4008079dfce203e63bf7a05582d7b9" "revision" : "e8b35fdd8c4008079dfce203e63bf7a05582d7b9"
} }
@@ -111,8 +111,8 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://github.com/matrix-org/matrix-rust-components-swift", "location" : "https://github.com/matrix-org/matrix-rust-components-swift",
"state" : { "state" : {
"revision" : "278e5694266e6b88b675d39a68391025b3b72bcb", "revision" : "59c10bfd0b2dee9b5bf41b536ffac472d4fc49db",
"version" : "1.0.78-alpha" "version" : "1.0.79-alpha"
} }
}, },
{ {
@@ -181,7 +181,7 @@
{ {
"identity" : "swift-snapshot-testing", "identity" : "swift-snapshot-testing",
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing", "location" : "https://github.com/pointfreeco/swift-snapshot-testing.git",
"state" : { "state" : {
"revision" : "cef5b3f6f11781dd4591bdd1dd0a3d22bd609334", "revision" : "cef5b3f6f11781dd4591bdd1dd0a3d22bd609334",
"version" : "1.11.0" "version" : "1.11.0"
@@ -652,27 +652,27 @@ class SDKClientMock: SDKClientProtocol {
} }
//MARK: - `uploadMedia` //MARK: - `uploadMedia`
public var uploadMediaMimeTypeDataThrowableError: Error? public var uploadMediaMimeTypeDataProgressWatcherThrowableError: Error?
public var uploadMediaMimeTypeDataCallsCount = 0 public var uploadMediaMimeTypeDataProgressWatcherCallsCount = 0
public var uploadMediaMimeTypeDataCalled: Bool { public var uploadMediaMimeTypeDataProgressWatcherCalled: Bool {
return uploadMediaMimeTypeDataCallsCount > 0 return uploadMediaMimeTypeDataProgressWatcherCallsCount > 0
} }
public var uploadMediaMimeTypeDataReceivedArguments: (`mimeType`: String, `data`: [UInt8])? public var uploadMediaMimeTypeDataProgressWatcherReceivedArguments: (`mimeType`: String, `data`: [UInt8], `progressWatcher`: ProgressWatcher?)?
public var uploadMediaMimeTypeDataReceivedInvocations: [(`mimeType`: String, `data`: [UInt8])] = [] public var uploadMediaMimeTypeDataProgressWatcherReceivedInvocations: [(`mimeType`: String, `data`: [UInt8], `progressWatcher`: ProgressWatcher?)] = []
public var uploadMediaMimeTypeDataReturnValue: String! public var uploadMediaMimeTypeDataProgressWatcherReturnValue: String!
public var uploadMediaMimeTypeDataClosure: ((String, [UInt8]) throws -> String)? public var uploadMediaMimeTypeDataProgressWatcherClosure: ((String, [UInt8], ProgressWatcher?) throws -> String)?
public func `uploadMedia`(`mimeType`: String, `data`: [UInt8]) throws -> String { public func `uploadMedia`(`mimeType`: String, `data`: [UInt8], `progressWatcher`: ProgressWatcher?) throws -> String {
if let error = uploadMediaMimeTypeDataThrowableError { if let error = uploadMediaMimeTypeDataProgressWatcherThrowableError {
throw error throw error
} }
uploadMediaMimeTypeDataCallsCount += 1 uploadMediaMimeTypeDataProgressWatcherCallsCount += 1
uploadMediaMimeTypeDataReceivedArguments = (mimeType: mimeType, data: data) uploadMediaMimeTypeDataProgressWatcherReceivedArguments = (mimeType: mimeType, data: data, progressWatcher: progressWatcher)
uploadMediaMimeTypeDataReceivedInvocations.append((mimeType: mimeType, data: data)) uploadMediaMimeTypeDataProgressWatcherReceivedInvocations.append((mimeType: mimeType, data: data, progressWatcher: progressWatcher))
if let uploadMediaMimeTypeDataClosure = uploadMediaMimeTypeDataClosure { if let uploadMediaMimeTypeDataProgressWatcherClosure = uploadMediaMimeTypeDataProgressWatcherClosure {
return try uploadMediaMimeTypeDataClosure(`mimeType`, `data`) return try uploadMediaMimeTypeDataProgressWatcherClosure(`mimeType`, `data`, `progressWatcher`)
} else { } else {
return uploadMediaMimeTypeDataReturnValue return uploadMediaMimeTypeDataProgressWatcherReturnValue
} }
} }
//MARK: - `userId` //MARK: - `userId`
@@ -47,7 +47,6 @@ class ClientProxy: ClientProxyProtocol {
private let clientQueue: DispatchQueue private let clientQueue: DispatchQueue
private var roomListService: RoomList? private var roomListService: RoomList?
private var roomListSyncTaskHandle: TaskHandle?
private var roomListStateUpdateTaskHandle: TaskHandle? private var roomListStateUpdateTaskHandle: TaskHandle?
var roomSummaryProvider: RoomSummaryProviderProtocol? var roomSummaryProvider: RoomSummaryProviderProtocol?
@@ -71,7 +70,7 @@ class ClientProxy: ClientProxyProtocol {
// These need to be inlined instead of using stopSync() // These need to be inlined instead of using stopSync()
// as we can't call async methods safely from deinit // as we can't call async methods safely from deinit
client.setDelegate(delegate: nil) client.setDelegate(delegate: nil)
roomListSyncTaskHandle?.cancel() try? roomListService?.stopSync()
} }
let callbacks = PassthroughSubject<ClientProxyCallback, Never>() let callbacks = PassthroughSubject<ClientProxyCallback, Never>()
@@ -123,7 +122,7 @@ class ClientProxy: ClientProxyProtocol {
} }
var isSyncing: Bool { var isSyncing: Bool {
roomListSyncTaskHandle != nil roomListService?.isSyncing() ?? false
} }
func startSync() { func startSync() {
@@ -132,13 +131,16 @@ class ClientProxy: ClientProxyProtocol {
return return
} }
roomListSyncTaskHandle = roomListService?.sync() roomListService?.sync()
} }
func stopSync() { func stopSync() {
MXLog.info("Stopping sync") MXLog.info("Stopping sync")
roomListSyncTaskHandle?.cancel() do {
roomListSyncTaskHandle = nil try roomListService?.stopSync()
} catch {
MXLog.error("Failed stopping room list service with error: \(error)")
}
} }
func directRoomForUserID(_ userID: String) async -> Result<String?, ClientProxyError> { func directRoomForUserID(_ userID: String) async -> Result<String?, ClientProxyError> {
@@ -192,7 +194,7 @@ class ClientProxy: ClientProxyProtocol {
return await Task.dispatch(on: clientQueue) { return await Task.dispatch(on: clientQueue) {
do { do {
let data = try Data(contentsOf: media.url) let data = try Data(contentsOf: media.url)
let matrixUrl = try self.client.uploadMedia(mimeType: mimeType, data: [UInt8](data)) let matrixUrl = try self.client.uploadMedia(mimeType: mimeType, data: [UInt8](data), progressWatcher: nil)
return .success(matrixUrl) return .success(matrixUrl)
} catch let error as ClientError { } catch let error as ClientError {
return .failure(ClientProxyError.failedUploadingMedia(error.code)) return .failure(ClientProxyError.failedUploadingMedia(error.code))
@@ -388,16 +390,14 @@ class ClientProxy: ClientProxyProtocol {
guard let self else { return } guard let self else { return }
MXLog.info("Received room list update: \(state)") MXLog.info("Received room list update: \(state)")
if state == .allRooms || state == .carryOn { // Restart the room list sync on every error for now
self.callbacks.send(.receivedSyncUpdate)
}
#warning("Not great, not terrible (ツ)")
if state == .terminated { if state == .terminated {
self.restartSync() self.restartSync()
} }
if state == .allRooms { if state == .running {
self.callbacks.send(.receivedSyncUpdate)
Task { Task {
// Subscribe to invites later as the underlying SlidingSync list is only added when entering AllRooms // Subscribe to invites later as the underlying SlidingSync list is only added when entering AllRooms
await self.inviteSummaryProvider?.subscribeIfNecessary(entriesFunction: roomListService.invites(listener:), await self.inviteSummaryProvider?.subscribeIfNecessary(entriesFunction: roomListService.invites(listener:),
@@ -283,6 +283,8 @@ extension NotificationItemProxyProtocol {
return try await processNotice(content: content, mediaProvider: mediaProvider) return try await processNotice(content: content, mediaProvider: mediaProvider)
case .text(content: let content): case .text(content: let content):
return try await processText(content: content, mediaProvider: mediaProvider) return try await processText(content: content, mediaProvider: mediaProvider)
case .location:
return processEmpty()
} }
} }
@@ -284,7 +284,7 @@ class RoomProxy: RoomProxyProtocol {
return await Task.dispatch(on: userInitiatedDispatchQueue) { return await Task.dispatch(on: userInitiatedDispatchQueue) {
do { do {
try self.room.sendImage(url: url.path(), thumbnailUrl: thumbnailURL.path(), imageInfo: imageInfo) try self.room.sendImage(url: url.path(), thumbnailUrl: thumbnailURL.path(), imageInfo: imageInfo, progressWatcher: nil)
return .success(()) return .success(())
} catch { } catch {
return .failure(.failedSendingMedia) return .failure(.failedSendingMedia)
@@ -300,7 +300,7 @@ class RoomProxy: RoomProxyProtocol {
return await Task.dispatch(on: userInitiatedDispatchQueue) { return await Task.dispatch(on: userInitiatedDispatchQueue) {
do { do {
try self.room.sendVideo(url: url.path(), thumbnailUrl: thumbnailURL.path(), videoInfo: videoInfo) try self.room.sendVideo(url: url.path(), thumbnailUrl: thumbnailURL.path(), videoInfo: videoInfo, progressWatcher: nil)
return .success(()) return .success(())
} catch { } catch {
return .failure(.failedSendingMedia) return .failure(.failedSendingMedia)
@@ -316,7 +316,7 @@ class RoomProxy: RoomProxyProtocol {
return await Task.dispatch(on: userInitiatedDispatchQueue) { return await Task.dispatch(on: userInitiatedDispatchQueue) {
do { do {
try self.room.sendAudio(url: url.path(), audioInfo: audioInfo) try self.room.sendAudio(url: url.path(), audioInfo: audioInfo, progressWatcher: nil)
return .success(()) return .success(())
} catch { } catch {
return .failure(.failedSendingMedia) return .failure(.failedSendingMedia)
@@ -332,7 +332,7 @@ class RoomProxy: RoomProxyProtocol {
return await Task.dispatch(on: userInitiatedDispatchQueue) { return await Task.dispatch(on: userInitiatedDispatchQueue) {
do { do {
try self.room.sendFile(url: url.path(), fileInfo: fileInfo) try self.room.sendFile(url: url.path(), fileInfo: fileInfo, progressWatcher: nil)
return .success(()) return .success(())
} catch { } catch {
return .failure(.failedSendingMedia) return .failure(.failedSendingMedia)
@@ -74,6 +74,8 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
return buildEmoteTimelineItem(for: eventItemProxy, messageTimelineItem, content, isOutgoing) return buildEmoteTimelineItem(for: eventItemProxy, messageTimelineItem, content, isOutgoing)
case .audio(let content): case .audio(let content):
return buildAudioTimelineItem(for: eventItemProxy, messageTimelineItem, content, isOutgoing) return buildAudioTimelineItem(for: eventItemProxy, messageTimelineItem, content, isOutgoing)
case .location:
return nil
case .none: case .none:
return nil return nil
} }
@@ -488,6 +490,8 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
replyContent = .text(buildTextTimelineItemContent(content)) replyContent = .text(buildTextTimelineItemContent(content))
case .video(let content): case .video(let content):
replyContent = .video(buildVideoTimelineItemContent(content)) replyContent = .video(buildVideoTimelineItemContent(content))
case .location:
return nil
case .none: case .none:
return nil return nil
} }
+1 -1
View File
@@ -44,7 +44,7 @@ include:
packages: packages:
MatrixRustSDK: MatrixRustSDK:
url: https://github.com/matrix-org/matrix-rust-components-swift url: https://github.com/matrix-org/matrix-rust-components-swift
exactVersion: 1.0.78-alpha exactVersion: 1.0.79-alpha
# path: ../matrix-rust-sdk # path: ../matrix-rust-sdk
DesignKit: DesignKit:
path: DesignKit path: DesignKit