From 858ba6ef37488b961cd79415dea29f721e2c1cd6 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Sun, 9 Dec 2018 09:39:01 -0500 Subject: [PATCH] fix missing video thumbnails in approval view --- .../AttachmentApprovalViewController.swift | 6 +++--- .../attachments/SignalAttachment.swift | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift b/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift index b91a3becf..aedddd26f 100644 --- a/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift +++ b/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift @@ -70,7 +70,7 @@ class SignalAttachmentItem: Hashable { func getThumbnailImage() -> Promise { return DispatchQueue.global().async(.promise) { () -> UIImage in - guard let image = self.attachment.image() else { + guard let image = self.attachment.staticThumbnail() else { throw SignalAttachmentItemError.noThumbnail } return image @@ -78,9 +78,9 @@ class SignalAttachmentItem: Hashable { switch result { case .fulfilled(let image): self.imageSize = image.size - default: break + case .rejected(let error): + owsFailDebug("failed with error: \(error)") } - } } diff --git a/SignalMessaging/attachments/SignalAttachment.swift b/SignalMessaging/attachments/SignalAttachment.swift index f9d0de947..9ee674743 100644 --- a/SignalMessaging/attachments/SignalAttachment.swift +++ b/SignalMessaging/attachments/SignalAttachment.swift @@ -263,6 +263,21 @@ public class SignalAttachment: NSObject { albumMessageId: message.uniqueId) } + @objc + public func staticThumbnail() -> UIImage? { + if isAnimatedImage { + return image() + } else if isImage { + return image() + } else if isVideo { + return videoPreview() + } else if isAudio { + return nil + } else { + return nil + } + } + @objc public func image() -> UIImage? { if let cachedImage = cachedImage {