Skip to content

Commit 0547273

Browse files
committed
Fix author's posts with attachments not loading
1 parent 81164d9 commit 0547273

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Modules/Sources/ParsingClient/Parsers/TopicParser.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,15 @@ public struct TopicParser {
171171
throw ParsingError.unknownAttachmentType(type)
172172
}
173173

174+
let downloadCount = (attachment[safe: 7] as? Int) ?? (attachment[safe: 4] as? Int)
175+
174176
let attachment = Post.Attachment(
175177
id: id,
176178
type: type,
177179
name: name,
178180
size: size,
179181
metadata: try parseAttachmentMetadata(attachment),
180-
downloadCount: attachment[safe: 7] as? Int // Only if attachment.count > 7
182+
downloadCount: downloadCount // Only if attachment.count > 7
181183
)
182184
attachments.append(attachment)
183185
}
@@ -187,7 +189,7 @@ public struct TopicParser {
187189
// MARK: - Attachment Metadata
188190

189191
private static func parseAttachmentMetadata(_ attachment: [Any]) throws(ParsingError) -> Post.Attachment.Metadata? {
190-
if attachment.count <= 4 {
192+
if attachment.count <= 5 {
191193
return nil
192194
}
193195

0 commit comments

Comments
 (0)