From 42762ad9070dbfe6b8037ec04e6502b7593d8d9a Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 11 Jan 2019 15:23:06 -0500 Subject: [PATCH] Allow taps in albums with failed images. --- .../ColorPickerViewController.swift | 7 +------ .../Cells/OWSMessageBubbleView.m | 14 +++++++++----- .../ConversationView/ConversationViewItem.h | 4 +--- .../ConversationView/ConversationViewItem.m | 18 +----------------- 4 files changed, 12 insertions(+), 31 deletions(-) diff --git a/Signal/src/ViewControllers/ColorPickerViewController.swift b/Signal/src/ViewControllers/ColorPickerViewController.swift index 429a80cc7..cec956a9f 100644 --- a/Signal/src/ViewControllers/ColorPickerViewController.swift +++ b/Signal/src/ViewControllers/ColorPickerViewController.swift @@ -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 { diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m index 73adb67f4..d9a40f81b 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m @@ -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; } diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.h b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.h index d106c8249..8bccb0604 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.h +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.h @@ -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 - diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m index d0783da92..11d520eb9 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m @@ -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