mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Allow previews in the timeline to include filtered galleries (#5943)
* remove the usage of the timeline kind override in favour of getting it properly from the timeline view model * allow the previews to include gallery items filtered by the allowed types when started outside the gallery sss asa * fix for actions not being forwarded to the timeline right * pr suggestions
This commit is contained in:
@@ -94,7 +94,7 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
}
|
||||
|
||||
func messageEventContent(for timelineItemID: TimelineItemIdentifier) async -> RoomMessageEventContentWithoutRelation? {
|
||||
guard let content = timelineItemProvider.itemProxies.firstEventTimelineItemUsingStableID(timelineItemID)?.content,
|
||||
guard let content = timelineItemProvider.itemProxies.firstEventTimelineItem(matching: timelineItemID)?.content,
|
||||
case let .msgLike(messageLikeContent) = content,
|
||||
case let .message(messageContent) = messageLikeContent.kind else {
|
||||
return nil
|
||||
@@ -663,15 +663,19 @@ private extension MatrixRustSDK.PollKind {
|
||||
}
|
||||
|
||||
extension Array where Element == TimelineItemProxy {
|
||||
func firstEventTimelineItemUsingStableID(_ id: TimelineItemIdentifier) -> EventTimelineItem? {
|
||||
for item in self {
|
||||
if case let .event(eventTimelineItem) = item {
|
||||
if eventTimelineItem.id.uniqueID == id.uniqueID {
|
||||
return eventTimelineItem.item
|
||||
}
|
||||
}
|
||||
/// The event matching the given identifier, found by the event itself as that is the only part of
|
||||
/// the identifier that can be compared across timelines. Identifiers that don't represent an event
|
||||
/// fall back to the unique ID.
|
||||
func firstEventTimelineItem(matching id: TimelineItemIdentifier) -> EventTimelineItem? {
|
||||
let eventTimelineItems = compactMap { item -> EventTimelineItemProxy? in
|
||||
guard case let .event(eventTimelineItem) = item else { return nil }
|
||||
return eventTimelineItem
|
||||
}
|
||||
|
||||
return nil
|
||||
guard let eventOrTransactionID = id.eventOrTransactionID else {
|
||||
return eventTimelineItems.first { $0.id.uniqueID == id.uniqueID }?.item
|
||||
}
|
||||
|
||||
return eventTimelineItems.first { $0.id.eventOrTransactionID == eventOrTransactionID }?.item
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user