fix missing video thumbnails in approval view

This commit is contained in:
Michael Kirk 2018-12-09 09:39:01 -05:00
parent d77d968bfd
commit 858ba6ef37
2 changed files with 18 additions and 3 deletions

View File

@ -70,7 +70,7 @@ class SignalAttachmentItem: Hashable {
func getThumbnailImage() -> Promise<UIImage> {
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)")
}
}
}

View File

@ -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 {