mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
unified the filtering of the gallery items
This commit is contained in:
+15
@@ -15,6 +15,21 @@ nonisolated struct GalleryRoomTimelineItemContent: Hashable {
|
||||
/// The original textual representation of the formatted caption directly from the event (usually HTML code)
|
||||
var formattedCaptionHTMLString: String?
|
||||
let items: [GalleryItem]
|
||||
|
||||
/// The attachments of the given types, paired with their position in the gallery so that they remain
|
||||
/// identifiable once separated from it. Attachments of an unknown type are never included as there's
|
||||
/// nothing to show for them.
|
||||
/// - Parameter allowedTypes: The types to include, or `nil` to include them all.
|
||||
func attachments(allowedTypes: [TimelineAllowedGalleryItemType]?) -> [(mediaIndex: Int, item: GalleryItem)] {
|
||||
items.enumerated().compactMap { mediaIndex, item in
|
||||
guard let allowedItemType = item.allowedItemType,
|
||||
allowedTypes?.contains(allowedItemType) ?? true else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return (mediaIndex, item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Identifies a single attachment within a gallery message.
|
||||
|
||||
Reference in New Issue
Block a user