From cf4fa840433e0c5bc3fc3c8bdc2f2c582b282e3e Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Thu, 8 Apr 2021 10:18:20 +1000 Subject: [PATCH] Fix content type handling --- .../Message Cells/Content Views/MediaPlaceholderView.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Session/Conversations/Message Cells/Content Views/MediaPlaceholderView.swift b/Session/Conversations/Message Cells/Content Views/MediaPlaceholderView.swift index 5f989a33e..3feaca735 100644 --- a/Session/Conversations/Message Cells/Content Views/MediaPlaceholderView.swift +++ b/Session/Conversations/Message Cells/Content Views/MediaPlaceholderView.swift @@ -25,7 +25,12 @@ final class MediaPlaceholderView : UIView { private func setUpViewHierarchy() { let (iconName, attachmentDescription): (String, String) = { - guard let contentType = viewItem.attachmentPointer?.contentType else { return ("actionsheet_document_black", "file") } // Should never occur + guard let message = viewItem.interaction as? TSIncomingMessage else { return ("actionsheet_document_black", "file") } // Should never occur + var attachments: [TSAttachment] = [] + Storage.read { transaction in + attachments = message.attachments(with: transaction) + } + guard let contentType = attachments.first?.contentType else { return ("actionsheet_document_black", "file") } // Should never occur if MIMETypeUtil.isAudio(contentType) { return ("Microphone", "audio") } if MIMETypeUtil.isImage(contentType) || MIMETypeUtil.isVideo(contentType) { return ("actionsheet_camera_roll_black", "media") } return ("actionsheet_document_black", "file")