From d81bbcf3b13863bfc3081ed7c0d95455e432c8d7 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Wed, 27 Sep 2023 12:51:05 +0300 Subject: [PATCH] Bump the Rust SDK to v1.1.20 and fix breaking API changes --- ElementX.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 4 +-- .../Sources/Services/Room/RoomProxy.swift | 28 +++++++------------ project.yml | 2 +- 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index 6bca242bc9..9d80a80f51 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -5765,7 +5765,7 @@ repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift"; requirement = { kind = exactVersion; - version = 1.1.19; + version = 1.1.20; }; }; 821C67C9A7F8CC3FD41B28B4 /* XCRemoteSwiftPackageReference "emojibase-bindings" */ = { diff --git a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index b3a5551d51..8a0be1eb16 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -129,8 +129,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/matrix-org/matrix-rust-components-swift", "state" : { - "revision" : "8f03dc0cdfc8aa7a4110fb3d6561090befc4d0c3", - "version" : "1.1.19" + "revision" : "5f3a195f6a461b4d40a8a705a3af8235711f12f5", + "version" : "1.1.20" } }, { diff --git a/ElementX/Sources/Services/Room/RoomProxy.swift b/ElementX/Sources/Services/Room/RoomProxy.swift index 193755a7e0..9f7c48705a 100644 --- a/ElementX/Sources/Services/Room/RoomProxy.swift +++ b/ElementX/Sources/Services/Room/RoomProxy.swift @@ -247,10 +247,8 @@ class RoomProxy: RoomProxyProtocol { sendMessageBackgroundTask?.stop() } - let transactionId = genTransactionId() - return await Task.dispatch(on: messageSendingDispatchQueue) { - self.room.send(msg: messageContent, txnId: transactionId) + self.room.send(msg: messageContent) return .success(()) } } @@ -261,7 +259,6 @@ class RoomProxy: RoomProxyProtocol { sendMessageBackgroundTask?.stop() } - let transactionId = genTransactionId() let messageContent: RoomMessageEventContentWithoutRelation if let html { messageContent = messageEventContentFromHtml(body: message, htmlBody: html) @@ -272,9 +269,9 @@ class RoomProxy: RoomProxyProtocol { do { if let eventID { let replyItem = try self.room.getEventTimelineItemByEventId(eventId: eventID) - try self.room.sendReply(msg: messageContent, replyItem: replyItem, txnId: transactionId) + try self.room.sendReply(msg: messageContent, replyItem: replyItem) } else { - self.room.send(msg: messageContent, txnId: transactionId) + self.room.send(msg: messageContent) } } catch { return .failure(.failedSendingMessage) @@ -407,15 +404,12 @@ class RoomProxy: RoomProxyProtocol { sendMessageBackgroundTask?.stop() } - let transactionId = genTransactionId() - return await Task.dispatch(on: messageSendingDispatchQueue) { .success(self.room.sendLocation(body: body, geoUri: geoURI.string, description: description, zoomLevel: zoomLevel, - assetType: assetType, - txnId: transactionId)) + assetType: assetType)) } } @@ -447,7 +441,6 @@ class RoomProxy: RoomProxyProtocol { sendMessageBackgroundTask?.stop() } - let transactionId = genTransactionId() let newMessageContent: RoomMessageEventContentWithoutRelation if let html { newMessageContent = messageEventContentFromHtml(body: newMessage, htmlBody: html) @@ -457,7 +450,8 @@ class RoomProxy: RoomProxyProtocol { return await Task.dispatch(on: messageSendingDispatchQueue) { do { - try self.room.edit(newMsg: newMessageContent, originalEventId: eventID, txnId: transactionId) + let originalEvent = try self.room.getEventTimelineItemByEventId(eventId: eventID) + try self.room.edit(newContent: newMessageContent, editItem: originalEvent) return .success(()) } catch { return .failure(.failedEditingMessage) @@ -471,11 +465,9 @@ class RoomProxy: RoomProxyProtocol { sendMessageBackgroundTask?.stop() } - let transactionID = genTransactionId() - return await Task.dispatch(on: userInitiatedDispatchQueue) { do { - try self.room.redact(eventId: eventID, reason: nil, txnId: transactionID) + try self.room.redact(eventId: eventID, reason: nil) return .success(()) } catch { return .failure(.failedRedactingEvent) @@ -684,7 +676,7 @@ class RoomProxy: RoomProxyProtocol { func createPoll(question: String, answers: [String], pollKind: Poll.Kind) async -> Result { await Task.dispatch(on: .global()) { do { - return try .success(self.room.createPoll(question: question, answers: answers, maxSelections: 1, pollKind: .init(pollKind: pollKind), txnId: genTransactionId())) + return try .success(self.room.createPoll(question: question, answers: answers, maxSelections: 1, pollKind: .init(pollKind: pollKind))) } catch { MXLog.error("Failed creating a poll: \(error)") return .failure(.failedCreatingPoll) @@ -695,7 +687,7 @@ class RoomProxy: RoomProxyProtocol { func sendPollResponse(pollStartID: String, answers: [String]) async -> Result { await Task.dispatch(on: .global()) { do { - return try .success(self.room.sendPollResponse(pollStartId: pollStartID, answers: answers, txnId: genTransactionId())) + return try .success(self.room.sendPollResponse(pollStartId: pollStartID, answers: answers)) } catch { MXLog.error("Failed sending a poll vote: \(error), pollStartID: \(pollStartID)") return .failure(.failedSendingPollResponse) @@ -706,7 +698,7 @@ class RoomProxy: RoomProxyProtocol { func endPoll(pollStartID: String, text: String) async -> Result { await Task.dispatch(on: .global()) { do { - return try .success(self.room.endPoll(pollStartId: pollStartID, text: text, txnId: genTransactionId())) + return try .success(self.room.endPoll(pollStartId: pollStartID, text: text)) } catch { MXLog.error("Failed ending a poll: \(error), pollStartID: \(pollStartID)") return .failure(.failedEndingPoll) diff --git a/project.yml b/project.yml index 4ab8742d5d..4ec39cb1c9 100644 --- a/project.yml +++ b/project.yml @@ -45,7 +45,7 @@ packages: # Element/Matrix dependencies MatrixRustSDK: url: https://github.com/matrix-org/matrix-rust-components-swift - exactVersion: 1.1.19 + exactVersion: 1.1.20 # path: ../matrix-rust-sdk DesignKit: path: DesignKit