Respond to CR.

This commit is contained in:
Matthew Chen 2019-03-18 14:24:33 -04:00
parent b6724ee181
commit df4cf5c09e
4 changed files with 12 additions and 4 deletions

View File

@ -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];

View File

@ -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;
}

View File

@ -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];

View File

@ -526,7 +526,7 @@ typedef void (^OWSLoadedThumbnailSuccess)(OWSLoadedThumbnail *loadedThumbnail);
}
}
- (CGSize)cachedImageSize
- (CGSize)cachedMediaSize
{
OWSAssertDebug(self.shouldHaveImageSize);