From 342ad57ce704332b31df3d4c49ab4f3f6db8ae30 Mon Sep 17 00:00:00 2001 From: Doug Date: Thu, 29 Aug 2024 14:39:49 +0100 Subject: [PATCH] Update the SDK. --- ElementX.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 4 +- .../Mocks/Generated/GeneratedMocks.swift | 14 +-- .../Mocks/Generated/SDKGeneratedMocks.swift | 112 +++--------------- .../RoomTimelineController.swift | 8 +- .../Services/Timeline/TimelineProxy.swift | 10 +- .../Timeline/TimelineProxyProtocol.swift | 2 +- project.yml | 2 +- 8 files changed, 37 insertions(+), 117 deletions(-) diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index 47d5b6e06..e10abb65b 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -7683,7 +7683,7 @@ repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift"; requirement = { kind = exactVersion; - version = 1.0.42; + version = 1.0.43; }; }; 701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = { diff --git a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 74f7fd10e..30a9e245c 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -149,8 +149,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/element-hq/matrix-rust-components-swift", "state" : { - "revision" : "ccae0615642728bbadcd051e4851d96ab298bab2", - "version" : "1.0.42" + "revision" : "4acde0099d719f9f176d0df3594efd3e34ffa431", + "version" : "1.0.43" } }, { diff --git a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift index 8aaaa2eb7..064d992c0 100644 --- a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift @@ -13854,8 +13854,8 @@ class TimelineProxyMock: TimelineProxyProtocol { var toggleReactionToCalled: Bool { return toggleReactionToCallsCount > 0 } - var toggleReactionToReceivedArguments: (reaction: String, eventID: String)? - var toggleReactionToReceivedInvocations: [(reaction: String, eventID: String)] = [] + var toggleReactionToReceivedArguments: (reaction: String, itemID: TimelineItemIdentifier)? + var toggleReactionToReceivedInvocations: [(reaction: String, itemID: TimelineItemIdentifier)] = [] var toggleReactionToUnderlyingReturnValue: Result! var toggleReactionToReturnValue: Result! { @@ -13881,16 +13881,16 @@ class TimelineProxyMock: TimelineProxyProtocol { } } } - var toggleReactionToClosure: ((String, String) async -> Result)? + var toggleReactionToClosure: ((String, TimelineItemIdentifier) async -> Result)? - func toggleReaction(_ reaction: String, to eventID: String) async -> Result { + func toggleReaction(_ reaction: String, to itemID: TimelineItemIdentifier) async -> Result { toggleReactionToCallsCount += 1 - toggleReactionToReceivedArguments = (reaction: reaction, eventID: eventID) + toggleReactionToReceivedArguments = (reaction: reaction, itemID: itemID) DispatchQueue.main.async { - self.toggleReactionToReceivedInvocations.append((reaction: reaction, eventID: eventID)) + self.toggleReactionToReceivedInvocations.append((reaction: reaction, itemID: itemID)) } if let toggleReactionToClosure = toggleReactionToClosure { - return await toggleReactionToClosure(reaction, eventID) + return await toggleReactionToClosure(reaction, itemID) } else { return toggleReactionToReturnValue } diff --git a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift index 8d2c52a05..80c231d0f 100644 --- a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift @@ -9974,82 +9974,6 @@ open class NotificationSettingsSDKMock: MatrixRustSDK.NotificationSettings { try await unmuteRoomRoomIdIsEncryptedIsOneToOneClosure?(roomId, isEncrypted, isOneToOne) } } -open class OidcAuthorizationDataSDKMock: MatrixRustSDK.OidcAuthorizationData { - init() { - super.init(noPointer: .init()) - } - - public required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { - fatalError("init(unsafeFromRawPointer:) has not been implemented") - } - - fileprivate var pointer: UnsafeMutableRawPointer! - - //MARK: - loginUrl - - var loginUrlUnderlyingCallsCount = 0 - open var loginUrlCallsCount: Int { - get { - if Thread.isMainThread { - return loginUrlUnderlyingCallsCount - } else { - var returnValue: Int? = nil - DispatchQueue.main.sync { - returnValue = loginUrlUnderlyingCallsCount - } - - return returnValue! - } - } - set { - if Thread.isMainThread { - loginUrlUnderlyingCallsCount = newValue - } else { - DispatchQueue.main.sync { - loginUrlUnderlyingCallsCount = newValue - } - } - } - } - open var loginUrlCalled: Bool { - return loginUrlCallsCount > 0 - } - - var loginUrlUnderlyingReturnValue: String! - open var loginUrlReturnValue: String! { - get { - if Thread.isMainThread { - return loginUrlUnderlyingReturnValue - } else { - var returnValue: String? = nil - DispatchQueue.main.sync { - returnValue = loginUrlUnderlyingReturnValue - } - - return returnValue! - } - } - set { - if Thread.isMainThread { - loginUrlUnderlyingReturnValue = newValue - } else { - DispatchQueue.main.sync { - loginUrlUnderlyingReturnValue = newValue - } - } - } - } - open var loginUrlClosure: (() -> String)? - - open override func loginUrl() -> String { - loginUrlCallsCount += 1 - if let loginUrlClosure = loginUrlClosure { - return loginUrlClosure() - } else { - return loginUrlReturnValue - } - } -} open class QrCodeDataSDKMock: MatrixRustSDK.QrCodeData { init() { super.init(noPointer: .init()) @@ -20067,16 +19991,16 @@ open class TimelineSDKMock: MatrixRustSDK.Timeline { //MARK: - toggleReaction - open var toggleReactionEventIdKeyThrowableError: Error? - var toggleReactionEventIdKeyUnderlyingCallsCount = 0 - open var toggleReactionEventIdKeyCallsCount: Int { + open var toggleReactionUniqueIdKeyThrowableError: Error? + var toggleReactionUniqueIdKeyUnderlyingCallsCount = 0 + open var toggleReactionUniqueIdKeyCallsCount: Int { get { if Thread.isMainThread { - return toggleReactionEventIdKeyUnderlyingCallsCount + return toggleReactionUniqueIdKeyUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = toggleReactionEventIdKeyUnderlyingCallsCount + returnValue = toggleReactionUniqueIdKeyUnderlyingCallsCount } return returnValue! @@ -20084,31 +20008,31 @@ open class TimelineSDKMock: MatrixRustSDK.Timeline { } set { if Thread.isMainThread { - toggleReactionEventIdKeyUnderlyingCallsCount = newValue + toggleReactionUniqueIdKeyUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - toggleReactionEventIdKeyUnderlyingCallsCount = newValue + toggleReactionUniqueIdKeyUnderlyingCallsCount = newValue } } } } - open var toggleReactionEventIdKeyCalled: Bool { - return toggleReactionEventIdKeyCallsCount > 0 + open var toggleReactionUniqueIdKeyCalled: Bool { + return toggleReactionUniqueIdKeyCallsCount > 0 } - open var toggleReactionEventIdKeyReceivedArguments: (eventId: String, key: String)? - open var toggleReactionEventIdKeyReceivedInvocations: [(eventId: String, key: String)] = [] - open var toggleReactionEventIdKeyClosure: ((String, String) async throws -> Void)? + open var toggleReactionUniqueIdKeyReceivedArguments: (uniqueId: String, key: String)? + open var toggleReactionUniqueIdKeyReceivedInvocations: [(uniqueId: String, key: String)] = [] + open var toggleReactionUniqueIdKeyClosure: ((String, String) async throws -> Void)? - open override func toggleReaction(eventId: String, key: String) async throws { - if let error = toggleReactionEventIdKeyThrowableError { + open override func toggleReaction(uniqueId: String, key: String) async throws { + if let error = toggleReactionUniqueIdKeyThrowableError { throw error } - toggleReactionEventIdKeyCallsCount += 1 - toggleReactionEventIdKeyReceivedArguments = (eventId: eventId, key: key) + toggleReactionUniqueIdKeyCallsCount += 1 + toggleReactionUniqueIdKeyReceivedArguments = (uniqueId: uniqueId, key: key) DispatchQueue.main.async { - self.toggleReactionEventIdKeyReceivedInvocations.append((eventId: eventId, key: key)) + self.toggleReactionUniqueIdKeyReceivedInvocations.append((uniqueId: uniqueId, key: key)) } - try await toggleReactionEventIdKeyClosure?(eventId, key) + try await toggleReactionUniqueIdKeyClosure?(uniqueId, key) } //MARK: - unpinEvent diff --git a/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineController.swift b/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineController.swift index bebbf9348..c3b783d0c 100644 --- a/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineController.swift +++ b/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineController.swift @@ -178,12 +178,8 @@ class RoomTimelineController: RoomTimelineControllerProtocol { func toggleReaction(_ reaction: String, to itemID: TimelineItemIdentifier) async { MXLog.info("Toggle reaction in \(roomID)") - guard let eventID = itemID.eventID else { - MXLog.error("Failed toggling reaction: missing eventID") - return - } - - switch await activeTimeline.toggleReaction(reaction, to: eventID) { + + switch await activeTimeline.toggleReaction(reaction, to: itemID) { case .success: MXLog.info("Finished toggling reaction") case .failure(let error): diff --git a/ElementX/Sources/Services/Timeline/TimelineProxy.swift b/ElementX/Sources/Services/Timeline/TimelineProxy.swift index 75cb650ba..8ae0d9ab3 100644 --- a/ElementX/Sources/Services/Timeline/TimelineProxy.swift +++ b/ElementX/Sources/Services/Timeline/TimelineProxy.swift @@ -430,15 +430,15 @@ final class TimelineProxy: TimelineProxyProtocol { } } - func toggleReaction(_ reaction: String, to eventID: String) async -> Result { - MXLog.info("Toggling reaction for eventID: \(eventID)") + func toggleReaction(_ reaction: String, to itemID: TimelineItemIdentifier) async -> Result { + MXLog.info("Toggling reaction for event: \(itemID)") do { - try await timeline.toggleReaction(eventId: eventID, key: reaction) - MXLog.info("Finished toggling reaction for eventID: \(eventID)") + try await timeline.toggleReaction(uniqueId: itemID.timelineID, key: reaction) + MXLog.info("Finished toggling reaction for event: \(itemID)") return .success(()) } catch { - MXLog.error("Failed toggling reaction for eventID: \(eventID)") + MXLog.error("Failed toggling reaction for event: \(itemID)") return .failure(.sdkError(error)) } } diff --git a/ElementX/Sources/Services/Timeline/TimelineProxyProtocol.swift b/ElementX/Sources/Services/Timeline/TimelineProxyProtocol.swift index 8c98bb3e6..3ea98bd68 100644 --- a/ElementX/Sources/Services/Timeline/TimelineProxyProtocol.swift +++ b/ElementX/Sources/Services/Timeline/TimelineProxyProtocol.swift @@ -101,7 +101,7 @@ protocol TimelineProxyProtocol { inReplyTo eventID: String?, intentionalMentions: IntentionalMentions) async -> Result - func toggleReaction(_ reaction: String, to eventID: String) async -> Result + func toggleReaction(_ reaction: String, to itemID: TimelineItemIdentifier) async -> Result // Polls func createPoll(question: String, answers: [String], pollKind: Poll.Kind) async -> Result diff --git a/project.yml b/project.yml index df67f7256..9a7d7c2c9 100644 --- a/project.yml +++ b/project.yml @@ -60,7 +60,7 @@ packages: # Element/Matrix dependencies MatrixRustSDK: url: https://github.com/element-hq/matrix-rust-components-swift - exactVersion: 1.0.42 + exactVersion: 1.0.43 # path: ../matrix-rust-sdk Compound: url: https://github.com/element-hq/compound-ios