potentially fix the conversation stuck at unread
This commit is contained in:
parent
bd7e9b5943
commit
69dea75486
|
@ -86,6 +86,11 @@ public final class AttachmentDownloadJob : NSObject, Job, NSCoding { // NSObject
|
|||
self.handlePermanentFailure(error: error)
|
||||
} else if let error = error as? OnionRequestAPI.Error, case .httpRequestFailedAtDestination(let statusCode, _, _) = error,
|
||||
statusCode == 400 {
|
||||
// Otherwise, the attachment will show a state of downloading forever,
|
||||
// and the message won't be able to be marked as read.
|
||||
storage.write(with: { transaction in
|
||||
storage.setAttachmentState(to: .failed, for: pointer, associatedWith: self.tsMessageID, using: transaction)
|
||||
}, completion: { })
|
||||
// This usually indicates a file that has expired on the server, so there's no need to retry.
|
||||
self.handlePermanentFailure(error: error)
|
||||
} else {
|
||||
|
|
|
@ -147,6 +147,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
BOOL areAllAttachmentsDownloaded = YES;
|
||||
for (NSString *attachmentId in self.attachmentIds) {
|
||||
TSAttachment *attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId transaction:transaction];
|
||||
// If the attachment download is failed, we can mark this message as read.
|
||||
// Otherwise, this message will never be marked as read.
|
||||
if ([attachment isKindOfClass:[TSAttachmentPointer class]] && ((TSAttachmentPointer *)attachment).state == TSAttachmentPointerStateFailed) {
|
||||
continue;
|
||||
}
|
||||
areAllAttachmentsDownloaded = areAllAttachmentsDownloaded && attachment.isDownloaded;
|
||||
if (!areAllAttachmentsDownloaded) break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue