Bump the Rust SDK to v1.1.20 and fix breaking API changes

This commit is contained in:
Stefan Ceriu
2023-09-27 12:51:05 +03:00
parent 8e43e66115
commit d81bbcf3b1
4 changed files with 14 additions and 22 deletions
+1 -1
View File
@@ -5765,7 +5765,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.1.19; version = 1.1.20;
}; };
}; };
821C67C9A7F8CC3FD41B28B4 /* XCRemoteSwiftPackageReference "emojibase-bindings" */ = { 821C67C9A7F8CC3FD41B28B4 /* XCRemoteSwiftPackageReference "emojibase-bindings" */ = {
@@ -129,8 +129,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" : "8f03dc0cdfc8aa7a4110fb3d6561090befc4d0c3", "revision" : "5f3a195f6a461b4d40a8a705a3af8235711f12f5",
"version" : "1.1.19" "version" : "1.1.20"
} }
}, },
{ {
+10 -18
View File
@@ -247,10 +247,8 @@ class RoomProxy: RoomProxyProtocol {
sendMessageBackgroundTask?.stop() sendMessageBackgroundTask?.stop()
} }
let transactionId = genTransactionId()
return await Task.dispatch(on: messageSendingDispatchQueue) { return await Task.dispatch(on: messageSendingDispatchQueue) {
self.room.send(msg: messageContent, txnId: transactionId) self.room.send(msg: messageContent)
return .success(()) return .success(())
} }
} }
@@ -261,7 +259,6 @@ class RoomProxy: RoomProxyProtocol {
sendMessageBackgroundTask?.stop() sendMessageBackgroundTask?.stop()
} }
let transactionId = genTransactionId()
let messageContent: RoomMessageEventContentWithoutRelation let messageContent: RoomMessageEventContentWithoutRelation
if let html { if let html {
messageContent = messageEventContentFromHtml(body: message, htmlBody: html) messageContent = messageEventContentFromHtml(body: message, htmlBody: html)
@@ -272,9 +269,9 @@ class RoomProxy: RoomProxyProtocol {
do { do {
if let eventID { if let eventID {
let replyItem = try self.room.getEventTimelineItemByEventId(eventId: 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 { } else {
self.room.send(msg: messageContent, txnId: transactionId) self.room.send(msg: messageContent)
} }
} catch { } catch {
return .failure(.failedSendingMessage) return .failure(.failedSendingMessage)
@@ -407,15 +404,12 @@ class RoomProxy: RoomProxyProtocol {
sendMessageBackgroundTask?.stop() sendMessageBackgroundTask?.stop()
} }
let transactionId = genTransactionId()
return await Task.dispatch(on: messageSendingDispatchQueue) { return await Task.dispatch(on: messageSendingDispatchQueue) {
.success(self.room.sendLocation(body: body, .success(self.room.sendLocation(body: body,
geoUri: geoURI.string, geoUri: geoURI.string,
description: description, description: description,
zoomLevel: zoomLevel, zoomLevel: zoomLevel,
assetType: assetType, assetType: assetType))
txnId: transactionId))
} }
} }
@@ -447,7 +441,6 @@ class RoomProxy: RoomProxyProtocol {
sendMessageBackgroundTask?.stop() sendMessageBackgroundTask?.stop()
} }
let transactionId = genTransactionId()
let newMessageContent: RoomMessageEventContentWithoutRelation let newMessageContent: RoomMessageEventContentWithoutRelation
if let html { if let html {
newMessageContent = messageEventContentFromHtml(body: newMessage, htmlBody: html) newMessageContent = messageEventContentFromHtml(body: newMessage, htmlBody: html)
@@ -457,7 +450,8 @@ class RoomProxy: RoomProxyProtocol {
return await Task.dispatch(on: messageSendingDispatchQueue) { return await Task.dispatch(on: messageSendingDispatchQueue) {
do { 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(()) return .success(())
} catch { } catch {
return .failure(.failedEditingMessage) return .failure(.failedEditingMessage)
@@ -471,11 +465,9 @@ class RoomProxy: RoomProxyProtocol {
sendMessageBackgroundTask?.stop() sendMessageBackgroundTask?.stop()
} }
let transactionID = genTransactionId()
return await Task.dispatch(on: userInitiatedDispatchQueue) { return await Task.dispatch(on: userInitiatedDispatchQueue) {
do { do {
try self.room.redact(eventId: eventID, reason: nil, txnId: transactionID) try self.room.redact(eventId: eventID, reason: nil)
return .success(()) return .success(())
} catch { } catch {
return .failure(.failedRedactingEvent) return .failure(.failedRedactingEvent)
@@ -684,7 +676,7 @@ class RoomProxy: RoomProxyProtocol {
func createPoll(question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, RoomProxyError> { func createPoll(question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, RoomProxyError> {
await Task.dispatch(on: .global()) { await Task.dispatch(on: .global()) {
do { 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 { } catch {
MXLog.error("Failed creating a poll: \(error)") MXLog.error("Failed creating a poll: \(error)")
return .failure(.failedCreatingPoll) return .failure(.failedCreatingPoll)
@@ -695,7 +687,7 @@ class RoomProxy: RoomProxyProtocol {
func sendPollResponse(pollStartID: String, answers: [String]) async -> Result<Void, RoomProxyError> { func sendPollResponse(pollStartID: String, answers: [String]) async -> Result<Void, RoomProxyError> {
await Task.dispatch(on: .global()) { await Task.dispatch(on: .global()) {
do { do {
return try .success(self.room.sendPollResponse(pollStartId: pollStartID, answers: answers, txnId: genTransactionId())) return try .success(self.room.sendPollResponse(pollStartId: pollStartID, answers: answers))
} catch { } catch {
MXLog.error("Failed sending a poll vote: \(error), pollStartID: \(pollStartID)") MXLog.error("Failed sending a poll vote: \(error), pollStartID: \(pollStartID)")
return .failure(.failedSendingPollResponse) return .failure(.failedSendingPollResponse)
@@ -706,7 +698,7 @@ class RoomProxy: RoomProxyProtocol {
func endPoll(pollStartID: String, text: String) async -> Result<Void, RoomProxyError> { func endPoll(pollStartID: String, text: String) async -> Result<Void, RoomProxyError> {
await Task.dispatch(on: .global()) { await Task.dispatch(on: .global()) {
do { do {
return try .success(self.room.endPoll(pollStartId: pollStartID, text: text, txnId: genTransactionId())) return try .success(self.room.endPoll(pollStartId: pollStartID, text: text))
} catch { } catch {
MXLog.error("Failed ending a poll: \(error), pollStartID: \(pollStartID)") MXLog.error("Failed ending a poll: \(error), pollStartID: \(pollStartID)")
return .failure(.failedEndingPoll) return .failure(.failedEndingPoll)
+1 -1
View File
@@ -45,7 +45,7 @@ packages:
# Element/Matrix dependencies # Element/Matrix dependencies
MatrixRustSDK: MatrixRustSDK:
url: https://github.com/matrix-org/matrix-rust-components-swift url: https://github.com/matrix-org/matrix-rust-components-swift
exactVersion: 1.1.19 exactVersion: 1.1.20
# path: ../matrix-rust-sdk # path: ../matrix-rust-sdk
DesignKit: DesignKit:
path: DesignKit path: DesignKit