|
|
|
@ -98,7 +98,6 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|
|
|
|
@property (nonatomic, nullable) TSAttachmentStream *attachmentStream;
|
|
|
|
|
@property (nonatomic, nullable) TSAttachmentPointer *attachmentPointer;
|
|
|
|
|
@property (nonatomic, nullable) ContactShareViewModel *contactShare;
|
|
|
|
|
@property (nonatomic, nullable) NSArray<TSAttachment *> *allMediaAlbumAttachments;
|
|
|
|
|
@property (nonatomic, nullable) NSArray<ConversationMediaAlbumItem *> *mediaAlbumItems;
|
|
|
|
|
@property (nonatomic, nullable) NSString *systemMessageText;
|
|
|
|
|
@property (nonatomic, nullable) TSThread *incomingMessageAuthorThread;
|
|
|
|
@ -163,7 +162,6 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|
|
|
|
self.displayableQuotedText = nil;
|
|
|
|
|
self.quotedReply = nil;
|
|
|
|
|
self.systemMessageText = nil;
|
|
|
|
|
self.allMediaAlbumAttachments = nil;
|
|
|
|
|
self.mediaAlbumItems = nil;
|
|
|
|
|
|
|
|
|
|
[self updateAuthorConversationColorNameWithTransaction:transaction];
|
|
|
|
@ -603,7 +601,6 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.allMediaAlbumAttachments = attachments;
|
|
|
|
|
self.mediaAlbumItems = mediaAlbumItems;
|
|
|
|
|
self.messageCellType = OWSMessageCellType_MediaAlbum;
|
|
|
|
|
NSString *_Nullable albumTitle = [message bodyTextWithTransaction:transaction];
|
|
|
|
@ -928,13 +925,9 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|
|
|
|
// TODO: We need a "canShareMediaAction" method.
|
|
|
|
|
OWSAssertDebug(self.mediaAlbumItems);
|
|
|
|
|
NSMutableArray<TSAttachmentStream *> *attachmentStreams = [NSMutableArray new];
|
|
|
|
|
for (TSAttachment *attachment in self.allMediaAlbumAttachments) {
|
|
|
|
|
if (![attachment isKindOfClass:[TSAttachmentStream class]]) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
TSAttachmentStream *attachmentStream = (TSAttachmentStream *)attachment;
|
|
|
|
|
if (attachmentStream.isValidVisualMedia) {
|
|
|
|
|
[attachmentStreams addObject:attachmentStream];
|
|
|
|
|
for (ConversationMediaAlbumItem *mediaAlbumItem in self.mediaAlbumItems) {
|
|
|
|
|
if (mediaAlbumItem.attachmentStream && mediaAlbumItem.attachmentStream.isValidVisualMedia) {
|
|
|
|
|
[attachmentStreams addObject:mediaAlbumItem.attachmentStream];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (attachmentStreams.count < 1) {
|
|
|
|
@ -1029,16 +1022,15 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|
|
|
|
case OWSMessageCellType_MediaAlbum: {
|
|
|
|
|
// TODO: Use PHPhotoLibrary.
|
|
|
|
|
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
|
|
|
|
|
for (TSAttachment *attachment in self.allMediaAlbumAttachments) {
|
|
|
|
|
if (![attachment isKindOfClass:[TSAttachmentStream class]]) {
|
|
|
|
|
for (ConversationMediaAlbumItem *mediaAlbumItem in self.mediaAlbumItems) {
|
|
|
|
|
if (!mediaAlbumItem.attachmentStream) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
TSAttachmentStream *attachmentStream = (TSAttachmentStream *)attachment;
|
|
|
|
|
if (!attachmentStream.isValidVisualMedia) {
|
|
|
|
|
if (!mediaAlbumItem.attachmentStream.isValidVisualMedia) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (attachmentStream.isImage || attachmentStream.isAnimated) {
|
|
|
|
|
NSData *data = [NSData dataWithContentsOfURL:[attachmentStream originalMediaURL]];
|
|
|
|
|
if (mediaAlbumItem.attachmentStream.isImage || mediaAlbumItem.attachmentStream.isAnimated) {
|
|
|
|
|
NSData *data = [NSData dataWithContentsOfURL:[mediaAlbumItem.attachmentStream originalMediaURL]];
|
|
|
|
|
if (!data) {
|
|
|
|
|
OWSFailDebug(@"Could not load image data");
|
|
|
|
|
continue;
|
|
|
|
@ -1051,9 +1043,11 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
if (attachmentStream.isVideo) {
|
|
|
|
|
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(attachmentStream.originalFilePath)) {
|
|
|
|
|
UISaveVideoAtPathToSavedPhotosAlbum(attachmentStream.originalFilePath, self, nil, nil);
|
|
|
|
|
if (mediaAlbumItem.attachmentStream.isVideo) {
|
|
|
|
|
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(
|
|
|
|
|
mediaAlbumItem.attachmentStream.originalFilePath)) {
|
|
|
|
|
UISaveVideoAtPathToSavedPhotosAlbum(
|
|
|
|
|
mediaAlbumItem.attachmentStream.originalFilePath, self, nil, nil);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|