Skip to content

Commit

Permalink
Update the SDK.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Aug 29, 2024
1 parent a11adfc commit 0b22144
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 117 deletions.
2 changes: 1 addition & 1 deletion ElementX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" */ = {
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" : "ccae0615642728bbadcd051e4851d96ab298bab2",
"version" : "1.0.42"
"revision" : "4acde0099d719f9f176d0df3594efd3e34ffa431",
"version" : "1.0.43"
}
},
{
Expand Down
14 changes: 7 additions & 7 deletions ElementX/Sources/Mocks/Generated/GeneratedMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void, TimelineProxyError>!
var toggleReactionToReturnValue: Result<Void, TimelineProxyError>! {
Expand All @@ -13881,16 +13881,16 @@ class TimelineProxyMock: TimelineProxyProtocol {
}
}
}
var toggleReactionToClosure: ((String, String) async -> Result<Void, TimelineProxyError>)?
var toggleReactionToClosure: ((String, TimelineItemIdentifier) async -> Result<Void, TimelineProxyError>)?

func toggleReaction(_ reaction: String, to eventID: String) async -> Result<Void, TimelineProxyError> {
func toggleReaction(_ reaction: String, to itemID: TimelineItemIdentifier) async -> Result<Void, TimelineProxyError> {
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
}
Expand Down
112 changes: 18 additions & 94 deletions ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -20067,48 +19991,48 @@ 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!
}
}
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
10 changes: 5 additions & 5 deletions ElementX/Sources/Services/Timeline/TimelineProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -430,15 +430,15 @@ final class TimelineProxy: TimelineProxyProtocol {
}
}

func toggleReaction(_ reaction: String, to eventID: String) async -> Result<Void, TimelineProxyError> {
MXLog.info("Toggling reaction for eventID: \(eventID)")
func toggleReaction(_ reaction: String, to itemID: TimelineItemIdentifier) async -> Result<Void, TimelineProxyError> {
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))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protocol TimelineProxyProtocol {
inReplyTo eventID: String?,
intentionalMentions: IntentionalMentions) async -> Result<Void, TimelineProxyError>

func toggleReaction(_ reaction: String, to eventID: String) async -> Result<Void, TimelineProxyError>
func toggleReaction(_ reaction: String, to itemID: TimelineItemIdentifier) async -> Result<Void, TimelineProxyError>

// Polls
func createPoll(question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, TimelineProxyError>
Expand Down
2 changes: 1 addition & 1 deletion project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0b22144

Please sign in to comment.