From d48001430490220fb5a5d221251af881e0a993e2 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Fri, 6 Feb 2026 12:08:44 +0200 Subject: [PATCH] Bump the RustSDK to v26.02.03 (#5051) Bump the RustSDK to v26.02.03 Fix breaking changes and add support for the new background task error reporting delegate and the new room invite latest event. --- ElementX.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 4 ++-- .../Sources/Services/Client/ClientProxy.swift | 22 ++++++++++++++++++- .../Services/Room/JoinedRoomProxy.swift | 11 +++++----- .../RoomSummary/RoomSummaryProvider.swift | 9 ++++++++ .../RoomStateEventStringBuilder.swift | 6 ++++- NSE/Sources/NSEUserSession.swift | 11 ++++++++++ .../Sources/Generated/SDKGeneratedMocks.swift | 18 --------------- project.yml | 2 +- 9 files changed, 56 insertions(+), 29 deletions(-) diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index 8f51741f3..8893c2891 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -9831,7 +9831,7 @@ repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift"; requirement = { kind = exactVersion; - version = 26.01.27; + version = 26.02.03; }; }; 701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = { diff --git a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 59b7df68d..9e2e3f452 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -158,8 +158,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/element-hq/matrix-rust-components-swift", "state" : { - "revision" : "f49e072a6629e69f374cff243319969f34f1f7f4", - "version" : "26.1.27" + "revision" : "a31fcfe93d38f37ce59695648d176c2f676edb62", + "version" : "26.2.3" } }, { diff --git a/ElementX/Sources/Services/Client/ClientProxy.swift b/ElementX/Sources/Services/Client/ClientProxy.swift index 0dcb736df..85977e24d 100644 --- a/ElementX/Sources/Services/Client/ClientProxy.swift +++ b/ElementX/Sources/Services/Client/ClientProxy.swift @@ -224,6 +224,19 @@ class ClientProxy: ClientProxyProtocol { delegateHandle = try client.setDelegate(delegate: ClientDelegateWrapper { [weak self] isSoftLogout in self?.hasEncounteredAuthError = true self?.actionsSubject.send(.receivedAuthError(isSoftLogout: isSoftLogout)) + } backgroundTaskErrorCallback: { error in + switch error { + case .panic(let message, let backtrace): + MXLog.error("Received background task panic: \(message ?? "Missing message")\nBacktrace:\n\(backtrace ?? "Missing backtrace")") + + if AppSettings.appBuildType == .debug || AppSettings.appBuildType == .nightly { + fatalError(message ?? "") + } + case .error(let error): + MXLog.error("Received background task error: \(error)") + case .earlyTermination: + MXLog.error("Received background task early termination") + } }) try await client.setUtdDelegate(utdDelegate: ClientDecryptionErrorDelegate(actionsSubject: actionsSubject)) @@ -1262,9 +1275,12 @@ class ClientProxy: ClientProxyProtocol { private final class ClientDelegateWrapper: ClientDelegate { private let authErrorCallback: @Sendable (Bool) -> Void + private let backgroundTaskErrorCallback: @Sendable (MatrixRustSDK.BackgroundTaskFailureReason) -> Void - init(authErrorCallback: @escaping @Sendable (Bool) -> Void) { + init(authErrorCallback: @escaping @Sendable (Bool) -> Void, + backgroundTaskErrorCallback: @escaping @Sendable (MatrixRustSDK.BackgroundTaskFailureReason) -> Void) { self.authErrorCallback = authErrorCallback + self.backgroundTaskErrorCallback = backgroundTaskErrorCallback } // MARK: - ClientDelegate @@ -1277,6 +1293,10 @@ private final class ClientDelegateWrapper: ClientDelegate { func didRefreshTokens() { MXLog.info("Delegating session updates to the ClientSessionDelegate.") } + + func onBackgroundTaskErrorReport(taskName: String, error: MatrixRustSDK.BackgroundTaskFailureReason) { + backgroundTaskErrorCallback(error) + } } private final class ClientDecryptionErrorDelegate: UnableToDecryptDelegate { diff --git a/ElementX/Sources/Services/Room/JoinedRoomProxy.swift b/ElementX/Sources/Services/Room/JoinedRoomProxy.swift index e96eafa3e..96bf370f3 100644 --- a/ElementX/Sources/Services/Room/JoinedRoomProxy.swift +++ b/ElementX/Sources/Services/Room/JoinedRoomProxy.swift @@ -88,7 +88,7 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol { let openRoomSpan = analyticsService.signpost.addSpan(.timelineLoad, toTransaction: .openRoom) timeline = try await TimelineProxy(timeline: room.timelineWithConfiguration(configuration: .init(focus: .live(hideThreadedEvents: appSettings.threadsEnabled), - filter: .eventTypeFilter(filter: excludedEventsFilter), + filter: .eventFilter(filter: excludedEventsFilter), internalIdPrefix: nil, dateDividerMode: .daily, trackReadReceipts: .messageLikeEvents, @@ -154,7 +154,7 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol { let openRoomSpan = analyticsService.signpost.addSpan(.timelineLoad, toTransaction: .notificationToMessage) let sdkTimeline = try await room.timelineWithConfiguration(configuration: .init(focus: .event(eventId: eventID, numContextEvents: numberOfEvents, - hideThreadedEvents: appSettings.threadsEnabled), + threadMode: .automatic(hideThreadedEvents: appSettings.threadsEnabled)), filter: .all, internalIdPrefix: UUID().uuidString, dateDividerMode: .daily, @@ -216,7 +216,7 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol { do { let rustFocus: MatrixRustSDK.TimelineFocus = switch focus { case .live: .live(hideThreadedEvents: false) - case .eventID(let eventID): .event(eventId: eventID, numContextEvents: 100, hideThreadedEvents: false) + case .eventID(let eventID): .event(eventId: eventID, numContextEvents: 100, threadMode: .automatic(hideThreadedEvents: false)) case .thread(let eventID): .thread(rootEventId: eventID) case .pinned: .pinnedEvents(maxEventsToLoad: 100, maxConcurrentRequests: 10) } @@ -792,7 +792,7 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol { } } - private let excludedEventsFilter: TimelineEventTypeFilter = { + private let excludedEventsFilter: TimelineEventFilter = { var stateEventFilters: [StateEventType] = [.roomAliases, .roomCanonicalAlias, .roomGuestAccess, @@ -807,6 +807,7 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol { .policyRuleRoom, .policyRuleServer, .policyRuleUser] - return .exclude(eventTypes: stateEventFilters.map { FilterTimelineEventType.state(eventType: $0) }) + + return .excludeEventTypes(eventTypes: stateEventFilters.map { FilterTimelineEventType.state(eventType: $0) }) }() } diff --git a/ElementX/Sources/Services/Room/RoomSummary/RoomSummaryProvider.swift b/ElementX/Sources/Services/Room/RoomSummary/RoomSummaryProvider.swift index 6a5848c1a..e166677ed 100644 --- a/ElementX/Sources/Services/Room/RoomSummary/RoomSummaryProvider.swift +++ b/ElementX/Sources/Services/Room/RoomSummary/RoomSummaryProvider.swift @@ -289,6 +289,15 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol { let sender = TimelineItemSender(senderID: senderID, senderProfile: profile) attributedLastMessage = eventStringBuilder.buildAttributedString(for: content, sender: sender, isOutgoing: isOwn) lastMessageDate = Date(timeIntervalSince1970: TimeInterval(timestamp / 1000)) + case .remoteInvite(let timestamp, let senderID, let profile): + lastMessageDate = Date(timeIntervalSince1970: TimeInterval(timestamp / 1000)) + + if let senderID { + let sender = TimelineItemSender(senderID: senderID, senderProfile: profile) + let senderDisplayName = sender.displayName ?? sender.id + let invitedYouString = eventStringBuilder.stateEventStringBuilder.buildInvitedYouString(senderDisplayName) + attributedLastMessage = AttributedString(invitedYouString) + } case .none: break } diff --git a/ElementX/Sources/Services/Timeline/TimelineItems/RoomStateEventStringBuilder.swift b/ElementX/Sources/Services/Timeline/TimelineItems/RoomStateEventStringBuilder.swift index 7253955df..e9df3bcc0 100644 --- a/ElementX/Sources/Services/Timeline/TimelineItems/RoomStateEventStringBuilder.swift +++ b/ElementX/Sources/Services/Timeline/TimelineItems/RoomStateEventStringBuilder.swift @@ -58,7 +58,7 @@ struct RoomStateEventStringBuilder { if senderIsYou { return L10n.stateEventRoomInviteByYou(member) } else if memberIsYou { - return L10n.stateEventRoomInviteYou(senderDisplayName) + return buildInvitedYouString(senderDisplayName) } else { return L10n.stateEventRoomInvite(senderDisplayName, member) } @@ -88,6 +88,10 @@ struct RoomStateEventStringBuilder { } } + func buildInvitedYouString(_ senderDisplayName: String) -> String { + L10n.stateEventRoomInviteYou(senderDisplayName) + } + func buildProfileChangeString(displayName: String?, previousDisplayName: String?, avatarURLString: String?, previousAvatarURLString: String?, member: String, memberIsYou: Bool) -> String? { diff --git a/NSE/Sources/NSEUserSession.swift b/NSE/Sources/NSEUserSession.swift index 30af77913..a509f1c08 100644 --- a/NSE/Sources/NSEUserSession.swift +++ b/NSE/Sources/NSEUserSession.swift @@ -140,4 +140,15 @@ private final class ClientDelegateWrapper: ClientDelegate { func didRefreshTokens() { MXLog.info("Delegating session updates to the ClientSessionDelegate.") } + + func onBackgroundTaskErrorReport(taskName: String, error: MatrixRustSDK.BackgroundTaskFailureReason) { + switch error { + case .panic(let message, let backtrace): + MXLog.error("Received background task panic: \(message ?? "Missing message")\nBacktrace:\n\(backtrace ?? "Missing backtrace")") + case .error(let error): + MXLog.error("Received background task error: \(error)") + case .earlyTermination: + MXLog.error("Received background task early termination") + } + } } diff --git a/SDKMocks/Sources/Generated/SDKGeneratedMocks.swift b/SDKMocks/Sources/Generated/SDKGeneratedMocks.swift index 2f5def68d..b2a57d6be 100644 --- a/SDKMocks/Sources/Generated/SDKGeneratedMocks.swift +++ b/SDKMocks/Sources/Generated/SDKGeneratedMocks.swift @@ -27862,24 +27862,6 @@ open class TimelineEventFilterSDKMock: MatrixRustSDK.TimelineEventFilter, @unche { } } -open class TimelineEventTypeFilterSDKMock: MatrixRustSDK.TimelineEventTypeFilter, @unchecked Sendable { - public init() { - super.init(noHandle: .init()) - } - - public required init(unsafeFromHandle handle: UInt64) { - fatalError("init(unsafeFromHandle:) has not been implemented") - } - - fileprivate var handle: UInt64 { - get { return underlyingHandle } - set(value) { underlyingHandle = value } - } - fileprivate var underlyingHandle: UInt64! - static func reset() - { - } -} open class TimelineItemSDKMock: MatrixRustSDK.TimelineItem, @unchecked Sendable { public init() { super.init(noHandle: .init()) diff --git a/project.yml b/project.yml index 0acb1f6f9..91f31dcbb 100644 --- a/project.yml +++ b/project.yml @@ -73,7 +73,7 @@ packages: # Element/Matrix dependencies MatrixRustSDK: url: https://github.com/element-hq/matrix-rust-components-swift - exactVersion: 26.01.27 + exactVersion: 26.02.03 # path: ../matrix-rust-sdk Compound: path: compound-ios