From bcbb0d93a45a33809c8d507c17dd0186ef4bbb98 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Wed, 23 Sep 2020 10:18:41 +1000 Subject: [PATCH] fix sending gif crash --- .../ConversationView/ConversationViewController.m | 8 ++++++++ .../AttachmentApproval/AttachmentPrepViewController.swift | 4 +++- SignalMessaging/ViewControllers/MediaMessageView.swift | 6 ++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index da6b6813a..9ef040390 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -4098,6 +4098,14 @@ typedef enum : NSUInteger { didApproveAttachments:(NSArray *)attachments messageText:(NSString *_Nullable)messageText { + for (SignalAttachment *attachment in attachments) { + if ([attachment hasError]) { + OWSLogWarn(@"Invalid attachment: %@.", attachment ? [attachment errorName] : @"Missing data"); + [self showErrorAlertForAttachment:attachment]; + return; + } + } + [self tryToSendAttachments:attachments messageText:messageText]; [self.inputToolbar clearTextMessageAnimated:NO]; [self resetMentions]; diff --git a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentPrepViewController.swift b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentPrepViewController.swift index 1615d8bbf..74408eab4 100644 --- a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentPrepViewController.swift +++ b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentPrepViewController.swift @@ -50,7 +50,9 @@ public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarD init(attachmentItem: SignalAttachmentItem) { self.attachmentItem = attachmentItem super.init(nibName: nil, bundle: nil) - assert(!attachment.hasError) + if attachment.hasError { + owsFailDebug(attachment.error.debugDescription) + } } public required init?(coder aDecoder: NSCoder) { diff --git a/SignalMessaging/ViewControllers/MediaMessageView.swift b/SignalMessaging/ViewControllers/MediaMessageView.swift index d1a3d5fa1..74f6def92 100644 --- a/SignalMessaging/ViewControllers/MediaMessageView.swift +++ b/SignalMessaging/ViewControllers/MediaMessageView.swift @@ -63,7 +63,9 @@ public class MediaMessageView: UIView, OWSAudioPlayerDelegate { // of nice that it's written in a flexible way in case we'd want to use it elsewhere again in the future. @objc public required init(attachment: SignalAttachment, mode: MediaMessageViewMode) { - assert(!attachment.hasError) + if attachment.hasError { + owsFailDebug(attachment.error.debugDescription) + } self.attachment = attachment self.mode = mode super.init(frame: CGRect.zero) @@ -336,7 +338,7 @@ public class MediaMessageView: UIView, OWSAudioPlayerDelegate { case .small, .large: return Colors.accent case .attachmentApproval: - return UIColor.white + return Colors.text } }