This commit is contained in:
Niels Andriesse 2020-02-04 10:25:37 +11:00
parent 37377c32df
commit eb54a6e06d
3 changed files with 22 additions and 11 deletions

View File

@ -26,8 +26,9 @@ public class ConversationMediaView: UIView {
public let attachment: TSAttachment
private let isOutgoing: Bool
private let maxMessageWidth: CGFloat
private var loadBlock : (() -> Void)?
private var unloadBlock : (() -> Void)?
private var loadBlock: (() -> Void)?
private var unloadBlock: (() -> Void)?
var isClosedGroup = false
// MARK: - LoadState
@ -173,12 +174,9 @@ public class ConversationMediaView: UIView {
}
private func addUploadProgressIfNecessary(_ subview: UIView) -> Bool {
guard isOutgoing else {
return false
}
guard let attachmentStream = attachment as? TSAttachmentStream else {
return false
}
guard !isClosedGroup else { return false } // Loki: Due to the way proxying works we can't get upload progress for closed group attachments right now
guard isOutgoing else { return false }
guard let attachmentStream = attachment as? TSAttachmentStream else { return false }
guard let attachmentId = attachmentStream.uniqueId else {
owsFailDebug("Attachment missing unique ID.")
configure(forError: .invalid)

View File

@ -26,13 +26,16 @@ public class MediaAlbumCellView: UIStackView {
public required init(mediaCache: NSCache<NSString, AnyObject>,
items: [ConversationMediaAlbumItem],
isOutgoing: Bool,
maxMessageWidth: CGFloat) {
maxMessageWidth: CGFloat,
isClosedGroup: Bool) {
self.items = items
self.itemViews = MediaAlbumCellView.itemsToDisplay(forItems: items).map {
ConversationMediaView(mediaCache: mediaCache,
let result = ConversationMediaView(mediaCache: mediaCache,
attachment: $0.attachment,
isOutgoing: isOutgoing,
maxMessageWidth: maxMessageWidth)
result.isClosedGroup = isClosedGroup
return result
}
super.init(frame: .zero)

View File

@ -799,11 +799,21 @@ NS_ASSUME_NONNULL_BEGIN
{
OWSAssertDebug(self.viewItem.mediaAlbumItems);
BOOL isClosedGroup = NO;
if ([self.viewItem isKindOfClass:TSOutgoingMessage.class]) {
TSOutgoingMessage *message = (TSOutgoingMessage *)self.viewItem;
if ([message.thread isKindOfClass:TSGroupThread.class]) {
TSGroupThread *groupThread = (TSGroupThread *)message.thread;
isClosedGroup = (groupThread.groupModel.groupType == closedGroup);
}
}
OWSMediaAlbumCellView *albumView =
[[OWSMediaAlbumCellView alloc] initWithMediaCache:self.cellMediaCache
items:self.viewItem.mediaAlbumItems
isOutgoing:self.isOutgoing
maxMessageWidth:self.conversationStyle.maxMessageWidth];
maxMessageWidth:self.conversationStyle.maxMessageWidth
isClosedGroup:isClosedGroup];
self.loadCellContentBlock = ^{
[albumView loadMedia];
};