Merge pull request #307 from RyanRory/retry-attachment-downloads-for-NSE
Fix Attachment Downloading
This commit is contained in:
commit
8003370b89
|
@ -1235,6 +1235,18 @@ static const int kYapDatabaseRangeMaxLength = 25000;
|
|||
OWSAssertDebug(!viewItemCache[interaction.uniqueId]);
|
||||
viewItemCache[interaction.uniqueId] = viewItem;
|
||||
[viewItems addObject:viewItem];
|
||||
TSMessage *message = (TSMessage *)viewItem.interaction;
|
||||
if (message.hasAttachmentsInNSE) {
|
||||
[SSKEnvironment.shared.attachmentDownloads downloadAttachmentsForMessage:message
|
||||
transaction:transaction
|
||||
success:^(NSArray<TSAttachmentStream *> *attachmentStreams) {
|
||||
OWSLogInfo(@"Successfully redownloaded attachment in thread: %@", message.thread);
|
||||
}
|
||||
failure:^(NSError *error) {
|
||||
OWSLogWarn(@"Failed to redownload message with error: %@", error);
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
return viewItem;
|
||||
};
|
||||
|
|
|
@ -290,6 +290,13 @@ typedef void (^AttachmentDownloadFailure)(NSError *error);
|
|||
[job.attachmentPointer saveWithTransaction:transaction];
|
||||
|
||||
if (job.message) {
|
||||
if (!CurrentAppContext().isMainApp) {
|
||||
job.message.hasAttachmentsInNSE = true;
|
||||
} else {
|
||||
job.message.hasAttachmentsInNSE = false;
|
||||
}
|
||||
|
||||
[job.message saveWithTransaction:transaction];
|
||||
[job.message touchWithTransaction:transaction];
|
||||
}
|
||||
}];
|
||||
|
|
|
@ -34,6 +34,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
// Open groups
|
||||
@property (nonatomic) uint64_t openGroupServerMessageID;
|
||||
@property (nonatomic, readonly) BOOL isOpenGroupMessage;
|
||||
// Attachments in NSE
|
||||
@property (nonatomic) BOOL hasAttachmentsInNSE;
|
||||
|
||||
- (instancetype)initInteractionWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread NS_UNAVAILABLE;
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
//
|
||||
|
||||
#import "OWSFailedAttachmentDownloadsJob.h"
|
||||
#import "SSKEnvironment.h"
|
||||
#import "OWSAttachmentDownloads.h"
|
||||
#import "OWSPrimaryStorage.h"
|
||||
#import "TSAttachmentPointer.h"
|
||||
#import <YapDatabase/YapDatabase.h>
|
||||
|
@ -25,6 +27,12 @@ static NSString *const OWSFailedAttachmentDownloadsJobAttachmentStateIndex = @"i
|
|||
|
||||
@implementation OWSFailedAttachmentDownloadsJob
|
||||
|
||||
- (OWSAttachmentDownloads *)attachmentDownloads
|
||||
{
|
||||
return SSKEnvironment.shared.attachmentDownloads;
|
||||
}
|
||||
|
||||
|
||||
- (instancetype)initWithPrimaryStorage:(OWSPrimaryStorage *)primaryStorage
|
||||
{
|
||||
self = [super init];
|
||||
|
|
Loading…
Reference in New Issue