Skip to content

Commit

Permalink
Bump the Rust SDK to v1.1.20 and fix breaking API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Sep 27, 2023
1 parent 8e43e66 commit d81bbcf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion ElementX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down
28 changes: 10 additions & 18 deletions ElementX/Sources/Services/Room/RoomProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}
Expand All @@ -261,7 +259,6 @@ class RoomProxy: RoomProxyProtocol {
sendMessageBackgroundTask?.stop()
}

let transactionId = genTransactionId()
let messageContent: RoomMessageEventContentWithoutRelation
if let html {
messageContent = messageEventContentFromHtml(body: message, htmlBody: html)
Expand All @@ -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)
Expand Down Expand Up @@ -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))
}
}

Expand Down Expand Up @@ -447,7 +441,6 @@ class RoomProxy: RoomProxyProtocol {
sendMessageBackgroundTask?.stop()
}

let transactionId = genTransactionId()
let newMessageContent: RoomMessageEventContentWithoutRelation
if let html {
newMessageContent = messageEventContentFromHtml(body: newMessage, htmlBody: html)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -684,7 +676,7 @@ class RoomProxy: RoomProxyProtocol {
func createPoll(question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, RoomProxyError> {
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)
Expand All @@ -695,7 +687,7 @@ class RoomProxy: RoomProxyProtocol {
func sendPollResponse(pollStartID: String, answers: [String]) async -> Result<Void, RoomProxyError> {
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)
Expand All @@ -706,7 +698,7 @@ class RoomProxy: RoomProxyProtocol {
func endPoll(pollStartID: String, text: String) async -> Result<Void, RoomProxyError> {
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)
Expand Down
2 changes: 1 addition & 1 deletion project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d81bbcf

Please sign in to comment.