From d58728864b2ea48d6592d79b98e9c10838d61a70 Mon Sep 17 00:00:00 2001 From: sbertix Date: Sat, 8 May 2021 14:10:43 +0200 Subject: [PATCH] fix(models): populate `items` in `Section` --- Sources/Swiftagram/Models/Specialized/Section.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Sources/Swiftagram/Models/Specialized/Section.swift b/Sources/Swiftagram/Models/Specialized/Section.swift index 1c6a8b76..e332826e 100644 --- a/Sources/Swiftagram/Models/Specialized/Section.swift +++ b/Sources/Swiftagram/Models/Specialized/Section.swift @@ -13,7 +13,16 @@ public struct Section: Wrapped { public var wrapper: () -> Wrapper /// Media in the response. - public var items: [Media]? { self["layoutContent"].medias.array()?.compactMap(Media.init) } + public var items: [Media]? { + self["layoutContent"] + .fillItems + .array()? + .compactMap { $0.media.optional().flatMap(Media.init) } + ?? self["layoutContent"] + .medias + .array()? + .compactMap { $0.media.optional().flatMap(Media.init) } + } /// Init. /// - parameter wrapper: A valid `Wrapper`.