removed identifier in the UIAction for opening a URL, also added a function to get a thread root from any event

This commit is contained in:
Mauro Romito
2025-09-30 18:07:18 +02:00
committed by Mauro
parent 94c42c81cc
commit 204b7c8297
4 changed files with 82 additions and 1 deletions
@@ -6483,6 +6483,76 @@ class JoinedRoomProxyMock: JoinedRoomProxyProtocol, @unchecked Sendable {
return threadTimelineEventIDReturnValue
}
}
//MARK: - getThreadRootEventID
var getThreadRootEventIDForUnderlyingCallsCount = 0
var getThreadRootEventIDForCallsCount: Int {
get {
if Thread.isMainThread {
return getThreadRootEventIDForUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = getThreadRootEventIDForUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
getThreadRootEventIDForUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
getThreadRootEventIDForUnderlyingCallsCount = newValue
}
}
}
}
var getThreadRootEventIDForCalled: Bool {
return getThreadRootEventIDForCallsCount > 0
}
var getThreadRootEventIDForReceivedEventID: String?
var getThreadRootEventIDForReceivedInvocations: [String] = []
var getThreadRootEventIDForUnderlyingReturnValue: Result<String?, RoomProxyError>!
var getThreadRootEventIDForReturnValue: Result<String?, RoomProxyError>! {
get {
if Thread.isMainThread {
return getThreadRootEventIDForUnderlyingReturnValue
} else {
var returnValue: Result<String?, RoomProxyError>? = nil
DispatchQueue.main.sync {
returnValue = getThreadRootEventIDForUnderlyingReturnValue
}
return returnValue!
}
}
set {
if Thread.isMainThread {
getThreadRootEventIDForUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
getThreadRootEventIDForUnderlyingReturnValue = newValue
}
}
}
}
var getThreadRootEventIDForClosure: ((String) async -> Result<String?, RoomProxyError>)?
func getThreadRootEventID(for eventID: String) async -> Result<String?, RoomProxyError> {
getThreadRootEventIDForCallsCount += 1
getThreadRootEventIDForReceivedEventID = eventID
DispatchQueue.main.async {
self.getThreadRootEventIDForReceivedInvocations.append(eventID)
}
if let getThreadRootEventIDForClosure = getThreadRootEventIDForClosure {
return await getThreadRootEventIDForClosure(eventID)
} else {
return getThreadRootEventIDForReturnValue
}
}
//MARK: - messageFilteredTimeline
var messageFilteredTimelineFocusAllowedMessageTypesPresentationUnderlyingCallsCount = 0
@@ -148,7 +148,6 @@ struct MessageText: UIViewRepresentable {
if case .link(let url) = textItem.content {
return .init(title: defaultAction.title,
image: defaultAction.image,
identifier: defaultAction.identifier,
discoverabilityTitle: defaultAction.discoverabilityTitle,
attributes: defaultAction.attributes,
state: defaultAction.state) { [weak self] _ in
@@ -190,6 +190,16 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
}
}
func getThreadRootEventID(for eventID: String) async -> Result<String?, RoomProxyError> {
do {
let event = try await room.loadOrFetchEvent(eventId: eventID)
return .success(event.threadRootEventId())
} catch {
MXLog.error("Failed fetching the event with id: \(eventID) with error: \(error)")
return .failure(.sdkError(error))
}
}
func messageFilteredTimeline(focus: TimelineFocus,
allowedMessageTypes: [TimelineAllowedMessageType],
presentation: TimelineKind.MediaPresentation) async -> Result<any TimelineProxyProtocol, RoomProxyError> {
@@ -97,6 +97,8 @@ protocol JoinedRoomProxyProtocol: RoomProxyProtocol {
func threadTimeline(eventID: String) async -> Result<TimelineProxyProtocol, RoomProxyError>
func getThreadRootEventID(for eventID: String) async -> Result<String?, RoomProxyError>
func messageFilteredTimeline(focus: TimelineFocus,
allowedMessageTypes: [TimelineAllowedMessageType],
presentation: TimelineKind.MediaPresentation) async -> Result<TimelineProxyProtocol, RoomProxyError>