Show gallery instead of large image when previewing status attachments

Fixes crash when attempting to preview audio/video attachments
This commit is contained in:
Shadowfacts 2020-02-28 19:47:38 -05:00
parent 56de0ab359
commit 5bed38f661
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 10 additions and 4 deletions

View File

@ -328,10 +328,16 @@ extension BaseStatusTableViewCell: MenuPreviewProvider {
)
} else if attachmentsView.frame.contains(location) {
let attachmentsViewLocation = attachmentsView.convert(location, from: self)
if let attachmentView = attachmentsView.attachmentViews.allObjects.first(where: { $0.frame.contains(attachmentsViewLocation) }),
let image = attachmentView.image {
let description = attachmentView.attachment.description
return (content: { self.delegate?.largeImage(image, description: description, sourceView: attachmentView) }, actions: { [] })
if let attachmentView = attachmentsView.attachmentViews.allObjects.first(where: { $0.frame.contains(attachmentsViewLocation) }) {
return (
content: {
let attachments = self.attachmentsView.attachments!
let sourceViews = attachments.map(self.attachmentsView.getAttachmentView(for:))
let startIndex = sourceViews.firstIndex(of: attachmentView)!
return self.delegate?.gallery(attachments: attachments, sourceViews: sourceViews, startIndex: startIndex)
},
actions: { [] }
)
}
}/* else if contentLabel.frame.contains(location),
let link = contentLabel.getLink(atPoint: contentLabel.convert(location, from: self)) {