Respond to CR.
This commit is contained in:
parent
42762ad907
commit
04a300784f
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
@ -11,6 +11,9 @@ public class MediaAlbumCellView: UIStackView {
|
|||
@objc
|
||||
public let itemViews: [ConversationMediaView]
|
||||
|
||||
@objc
|
||||
public var moreItemsView: ConversationMediaView?
|
||||
|
||||
private static let kSpacingPts: CGFloat = 2
|
||||
private static let kMaxItems = 5
|
||||
|
||||
|
@ -41,8 +44,6 @@ public class MediaAlbumCellView: UIStackView {
|
|||
}
|
||||
|
||||
private func createContents(maxMessageWidth: CGFloat) {
|
||||
var moreItemViews = [ConversationMediaView]()
|
||||
|
||||
switch itemViews.count {
|
||||
case 0:
|
||||
owsFailDebug("No item views.")
|
||||
|
@ -129,7 +130,7 @@ public class MediaAlbumCellView: UIStackView {
|
|||
return
|
||||
}
|
||||
|
||||
moreItemViews.append(lastView)
|
||||
moreItemsView = lastView
|
||||
|
||||
let tintView = UIView()
|
||||
tintView.backgroundColor = UIColor(white: 0, alpha: 0.4)
|
||||
|
@ -151,7 +152,7 @@ public class MediaAlbumCellView: UIStackView {
|
|||
}
|
||||
|
||||
for itemView in itemViews {
|
||||
guard !moreItemViews.contains(itemView) else {
|
||||
guard moreItemsView == itemView else {
|
||||
// Don't display the caption indicator on
|
||||
// the "more" item, if any.
|
||||
continue
|
||||
|
@ -277,4 +278,9 @@ public class MediaAlbumCellView: UIStackView {
|
|||
}
|
||||
return bestMediaView
|
||||
}
|
||||
|
||||
@objc
|
||||
public func isMoreItemsView(mediaView: ConversationMediaView) -> Bool {
|
||||
return moreItemsView == mediaView
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1388,16 +1388,28 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
|
|||
return;
|
||||
}
|
||||
|
||||
TSAttachment *attachment = mediaView.attachment;
|
||||
if (![attachment isKindOfClass:[TSAttachmentStream class]]) {
|
||||
if ([attachment isKindOfClass:[TSAttachmentPointer class]]) {
|
||||
TSAttachmentPointer *attachmentPointer = (TSAttachmentPointer *)attachment;
|
||||
if (attachmentPointer.state == TSAttachmentPointerStateFailed) {
|
||||
if ([mediaAlbumCellView isMoreItemsViewWithMediaView:mediaView]) {
|
||||
for (ConversationMediaAlbumItem *mediaAlbumItem in self.viewItem.mediaAlbumItems) {
|
||||
if (mediaAlbumItem.isFailedDownload) {
|
||||
// Treat the tap as a "retry" tap if:
|
||||
//
|
||||
// a) the user tapped on the "more items" cell.
|
||||
// b) there are any failed downloads in the album.
|
||||
[self.delegate didTapFailedIncomingAttachment:self.viewItem];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TSAttachment *attachment = mediaView.attachment;
|
||||
if ([attachment isKindOfClass:[TSAttachmentPointer class]]) {
|
||||
TSAttachmentPointer *attachmentPointer = (TSAttachmentPointer *)attachment;
|
||||
if (attachmentPointer.state == TSAttachmentPointerStateFailed) {
|
||||
// Treat the tap as a "retry" tap if the user taps on a failed download.
|
||||
[self.delegate didTapFailedIncomingAttachment:self.viewItem];
|
||||
return;
|
||||
}
|
||||
} else if (![attachment isKindOfClass:[TSAttachmentStream class]]) {
|
||||
OWSLogWarn(@"Media attachment not yet downloaded.");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,8 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType);
|
|||
|
||||
@property (nonatomic, readonly, nullable) NSString *caption;
|
||||
|
||||
@property (nonatomic, readonly) BOOL isFailedDownload;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
|
|
@ -64,6 +64,16 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)isFailedDownload
|
||||
{
|
||||
if (![self.attachment isKindOfClass:[TSAttachmentPointer class]]) {
|
||||
return NO;
|
||||
}
|
||||
TSAttachmentPointer *attachmentPointer = (TSAttachmentPointer *)self.attachment;
|
||||
return attachmentPointer.state == TSAttachmentPointerStateFailed;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
|
Loading…
Reference in New Issue