Allow taps in albums with failed images.

This commit is contained in:
Matthew Chen 2019-01-11 15:23:06 -05:00
parent b6e28adfe3
commit 42762ad907
4 changed files with 12 additions and 31 deletions

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
import Foundation
@ -434,11 +434,6 @@ private class MockConversationViewItem: NSObject, ConversationViewItem {
owsFailDebug("unexpected invocation")
return nil
}
func mediaAlbumHasFailedAttachment() -> Bool {
owsFailDebug("unexpected invocation")
return false
}
}
private class MockIncomingMessage: TSIncomingMessage {

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "OWSMessageBubbleView.h"
@ -1376,10 +1376,6 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
OWSAssertDebug(self.bodyMediaView);
OWSAssertDebug(self.viewItem.mediaAlbumItems.count > 0);
if (self.viewItem.mediaAlbumHasFailedAttachment) {
[self.delegate didTapFailedIncomingAttachment:self.viewItem];
return;
}
if (![self.bodyMediaView isKindOfClass:[OWSMediaAlbumCellView class]]) {
OWSFailDebug(@"Unexpected body media view: %@", self.bodyMediaView.class);
return;
@ -1394,6 +1390,14 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
TSAttachment *attachment = mediaView.attachment;
if (![attachment isKindOfClass:[TSAttachmentStream class]]) {
if ([attachment isKindOfClass:[TSAttachmentPointer class]]) {
TSAttachmentPointer *attachmentPointer = (TSAttachmentPointer *)attachment;
if (attachmentPointer.state == TSAttachmentPointerStateFailed) {
[self.delegate didTapFailedIncomingAttachment:self.viewItem];
return;
}
}
OWSLogWarn(@"Media attachment not yet downloaded.");
return;
}

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "ConversationViewLayout.h"
@ -144,8 +144,6 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType);
- (nullable TSAttachmentStream *)firstValidAlbumAttachment;
- (BOOL)mediaAlbumHasFailedAttachment;
@end
#pragma mark -

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "ConversationViewItem.h"
@ -1074,22 +1074,6 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
}
}
- (BOOL)mediaAlbumHasFailedAttachment
{
OWSAssertDebug(self.messageCellType == OWSMessageCellType_MediaAlbum);
OWSAssertDebug(self.mediaAlbumItems.count > 0);
for (ConversationMediaAlbumItem *mediaAlbumItem in self.mediaAlbumItems) {
if ([mediaAlbumItem.attachment isKindOfClass:[TSAttachmentPointer class]]) {
TSAttachmentPointer *attachmentPointer = (TSAttachmentPointer *)mediaAlbumItem.attachment;
if (attachmentPointer.state == TSAttachmentPointerStateFailed) {
return YES;
}
}
}
return NO;
}
@end
NS_ASSUME_NONNULL_END