From df4cf5c09e8bf0c45968dc8aceed7a8d104876b7 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 18 Mar 2019 14:24:33 -0400 Subject: [PATCH] Respond to CR. --- .../ConversationView/Cells/OWSGenericAttachmentView.m | 3 +++ .../ConversationView/ConversationViewItem.m | 3 +++ .../src/Messages/Attachments/TSAttachmentPointer.m | 8 +++++--- .../src/Messages/Attachments/TSAttachmentStream.m | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m index b4895613d..b95fd220d 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m @@ -159,6 +159,9 @@ NS_ASSUME_NONNULL_BEGIN .fileSize; OWSAssertDebug(!error); } + // We don't want to show the file size while the attachment is downloading. + // To avoid layout jitter when the download completes, we reserve space in + // the layout using a whitespace string. NSString *bottomText = @" "; if (fileSize > 0) { bottomText = [OWSFormat formatFileSize:fileSize]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m index d7f53ad92..5999f6731 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m @@ -990,6 +990,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) - (BOOL)canCopyMedia { if (self.attachmentPointer != nil) { + // The attachment is still downloading. return NO; } @@ -1018,6 +1019,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) - (BOOL)canSaveMedia { if (self.attachmentPointer != nil) { + // The attachment is still downloading. return NO; } @@ -1143,6 +1145,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) - (BOOL)hasMediaActionContent { if (self.attachmentPointer != nil) { + // The attachment is still downloading. return NO; } diff --git a/SignalServiceKit/src/Messages/Attachments/TSAttachmentPointer.m b/SignalServiceKit/src/Messages/Attachments/TSAttachmentPointer.m index da2684f01..0e04b52bd 100644 --- a/SignalServiceKit/src/Messages/Attachments/TSAttachmentPointer.m +++ b/SignalServiceKit/src/Messages/Attachments/TSAttachmentPointer.m @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN @interface TSAttachmentStream (TSAttachmentPointer) -- (CGSize)cachedImageSize; +- (CGSize)cachedMediaSize; @end @@ -100,7 +100,7 @@ NS_ASSUME_NONNULL_BEGIN _state = TSAttachmentPointerStateEnqueued; self.attachmentType = attachmentStream.attachmentType; _pointerType = TSAttachmentPointerTypeRestoring; - _mediaSize = (attachmentStream.shouldHaveImageSize ? attachmentStream.cachedImageSize : CGSizeZero); + _mediaSize = (attachmentStream.shouldHaveImageSize ? attachmentStream.cachedMediaSize : CGSizeZero); return self; } @@ -119,7 +119,9 @@ NS_ASSUME_NONNULL_BEGIN NSString *_Nullable fileName = attachmentProto.fileName; NSString *_Nullable contentType = attachmentProto.contentType; if (contentType.length < 1) { - OWSLogError(@"Invalid attachment content type."); + // Content type might not set if the sending client can't + // infer a MIME type from the file extension. + OWSLogWarn(@"Invalid attachment content type."); NSString *_Nullable fileExtension = [fileName pathExtension].lowercaseString; if (fileExtension.length > 0) { contentType = [MIMETypeUtil mimeTypeForFileExtension:fileExtension]; diff --git a/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m b/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m index bb0384d8d..8fba29f15 100644 --- a/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m +++ b/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m @@ -526,7 +526,7 @@ typedef void (^OWSLoadedThumbnailSuccess)(OWSLoadedThumbnail *loadedThumbnail); } } -- (CGSize)cachedImageSize +- (CGSize)cachedMediaSize { OWSAssertDebug(self.shouldHaveImageSize);