Skip to content

Commit

Permalink
Bump the SDK to v25.01.10-2, fix breaking API changes around sending …
Browse files Browse the repository at this point in the history
…media and mentions
  • Loading branch information
stefanceriu committed Jan 10, 2025
1 parent c6e6be7 commit 3e4c021
Show file tree
Hide file tree
Showing 7 changed files with 275 additions and 181 deletions.
2 changes: 1 addition & 1 deletion ElementX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8415,7 +8415,7 @@
repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift";
requirement = {
kind = exactVersion;
version = 24.12.20;
version = "25.01.10-2";
};
};
701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/element-hq/matrix-rust-components-swift",
"state" : {
"revision" : "3047d2b193a437b53998fa0133c46f198ee57126",
"version" : "24.12.20"
"revision" : "cc9cd80aa6954a7945d82c29182f81c5219f635e",
"version" : "25.1.10-2"
}
},
{
Expand Down
339 changes: 214 additions & 125 deletions ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion ElementX/Sources/Mocks/PhotoLibraryManagerMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ extension PhotoLibraryManagerMock {
var authorizationDenied = false
}

// swiftlint:disable:next cyclomatic_complexity
convenience init(_ configuration: Configuration) {
self.init()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,12 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
message: String,
html: String?,
intentionalMentions: IntentionalMentions) async {
// We're waiting on an API for including mentions: https://github.com/matrix-org/matrix-rust-sdk/issues/4302
MXLog.info("Editing timeline item caption: \(eventOrTransactionID) in \(roomID)")

// When formattedCaption is nil, caption will be parsed as markdown and generate the HTML for us.
let newContent = createCaptionEdit(caption: message, formattedCaption: html.map { .init(format: .html, body: $0) })
let newContent = createCaptionEdit(caption: message,
formattedCaption: html.map { .init(format: .html, body: $0) },
mentions: intentionalMentions.toRustMentions())
switch await activeTimeline.edit(eventOrTransactionID, newContent: newContent) {
case .success:
MXLog.info("Finished editing caption")
Expand All @@ -270,7 +271,7 @@ class RoomTimelineController: RoomTimelineControllerProtocol {

func removeCaption(_ eventOrTransactionID: EventOrTransactionId) async {
// Set a `nil` caption to remove it from the event.
let newContent = createCaptionEdit(caption: nil, formattedCaption: nil)
let newContent = createCaptionEdit(caption: nil, formattedCaption: nil, mentions: nil)
switch await activeTimeline.edit(eventOrTransactionID, newContent: newContent) {
case .success:
MXLog.info("Finished removing caption.")
Expand Down
101 changes: 53 additions & 48 deletions ElementX/Sources/Services/Timeline/TimelineProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,17 @@ final class TimelineProxy: TimelineProxyProtocol {
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
MXLog.info("Sending audio")

let handle = timeline.sendAudio(url: url.path(percentEncoded: false),
audioInfo: audioInfo,
caption: caption,
formattedCaption: nil, // Rust will build this from the caption's markdown.
progressWatcher: nil,
useSendQueue: true)

await requestHandle(handle)

do {
let handle = try timeline.sendAudio(params: .init(filename: url.path(percentEncoded: false),
caption: caption,
formattedCaption: nil, // Rust will build this from the caption's markdown.
mentions: nil,
useSendQueue: true),
audioInfo: audioInfo,
progressWatcher: nil)

await requestHandle(handle)

try await handle.join()
MXLog.info("Finished sending audio")
} catch {
Expand All @@ -255,16 +256,17 @@ final class TimelineProxy: TimelineProxyProtocol {
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
MXLog.info("Sending file")

let handle = timeline.sendFile(url: url.path(percentEncoded: false),
fileInfo: fileInfo,
caption: caption,
formattedCaption: nil, // Rust will build this from the caption's markdown.
progressWatcher: nil,
useSendQueue: true)

await requestHandle(handle)

do {
let handle = try timeline.sendFile(params: .init(filename: url.path(percentEncoded: false),
caption: caption,
formattedCaption: nil, // Rust will build this from the caption's markdown.
mentions: nil,
useSendQueue: true),
fileInfo: fileInfo,
progressWatcher: nil)

await requestHandle(handle)

try await handle.join()
MXLog.info("Finished sending file")
} catch {
Expand All @@ -282,17 +284,18 @@ final class TimelineProxy: TimelineProxyProtocol {
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
MXLog.info("Sending image")

let handle = timeline.sendImage(url: url.path(percentEncoded: false),
thumbnailUrl: thumbnailURL.path(percentEncoded: false),
imageInfo: imageInfo,
caption: caption,
formattedCaption: nil, // Rust will build this from the caption's markdown.
progressWatcher: nil,
useSendQueue: true)

await requestHandle(handle)

do {
let handle = try timeline.sendImage(params: .init(filename: url.path(percentEncoded: false),
caption: caption,
formattedCaption: nil, // Rust will build this from the caption's markdown.
mentions: nil,
useSendQueue: true),
thumbnailPath: thumbnailURL.path(percentEncoded: false),
imageInfo: imageInfo,
progressWatcher: nil)

await requestHandle(handle)

try await handle.join()
MXLog.info("Finished sending image")
} catch {
Expand Down Expand Up @@ -328,17 +331,18 @@ final class TimelineProxy: TimelineProxyProtocol {
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
MXLog.info("Sending video")

let handle = timeline.sendVideo(url: url.path(percentEncoded: false),
thumbnailUrl: thumbnailURL.path(percentEncoded: false),
videoInfo: videoInfo,
caption: caption,
formattedCaption: nil, // Rust will build this from the caption's markdown.
progressWatcher: nil,
useSendQueue: true)

await requestHandle(handle)

do {
let handle = try timeline.sendVideo(params: .init(filename: url.path(percentEncoded: false),
caption: caption,
formattedCaption: nil,
mentions: nil,
useSendQueue: true),
thumbnailPath: thumbnailURL.path(percentEncoded: false),
videoInfo: videoInfo,
progressWatcher: nil)

await requestHandle(handle)

try await handle.join()
MXLog.info("Finished sending video")
} catch {
Expand All @@ -355,17 +359,18 @@ final class TimelineProxy: TimelineProxyProtocol {
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
MXLog.info("Sending voice message")

let handle = timeline.sendVoiceMessage(url: url.path(percentEncoded: false),
audioInfo: audioInfo,
waveform: waveform,
caption: nil,
formattedCaption: nil,
progressWatcher: nil,
useSendQueue: true)

await requestHandle(handle)

do {
let handle = try timeline.sendVoiceMessage(params: .init(filename: url.path(percentEncoded: false),
caption: nil,
formattedCaption: nil,
mentions: nil,
useSendQueue: true),
audioInfo: audioInfo,
waveform: waveform,
progressWatcher: nil)

await requestHandle(handle)

try await handle.join()
MXLog.info("Finished sending voice message")
} catch {
Expand Down
2 changes: 1 addition & 1 deletion project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ packages:
# Element/Matrix dependencies
MatrixRustSDK:
url: https://github.com/element-hq/matrix-rust-components-swift
exactVersion: 24.12.20
exactVersion: 25.01.10-2
# path: ../matrix-rust-sdk
Compound:
url: https://github.com/element-hq/compound-ios
Expand Down

0 comments on commit 3e4c021

Please sign in to comment.