diff --git a/Session/Conversations/ConversationVC.swift b/Session/Conversations/ConversationVC.swift index b048216b8..f0aeb67fc 100644 --- a/Session/Conversations/ConversationVC.swift +++ b/Session/Conversations/ConversationVC.swift @@ -354,6 +354,7 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat // the previous value when the keyboard is shown. self.messagesTableView.reloadData() } + self.markAllAsRead() } if shouldAnimate { messagesTableView.performBatchUpdates(batchUpdates, completion: batchUpdatesCompletion) diff --git a/SessionMessagingKit/Messages/Signal/TSIncomingMessage.m b/SessionMessagingKit/Messages/Signal/TSIncomingMessage.m index e452327b3..908d53f42 100644 --- a/SessionMessagingKit/Messages/Signal/TSIncomingMessage.m +++ b/SessionMessagingKit/Messages/Signal/TSIncomingMessage.m @@ -144,6 +144,17 @@ NS_ASSUME_NONNULL_BEGIN return; } + BOOL isAllAttachmentDownloaded = YES; + for (NSString *attachmentId in self.attachmentIds) { + TSAttachment *attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId transaction:transaction]; + isAllAttachmentDownloaded = isAllAttachmentDownloaded && attachment.isDownloaded; + if (!isAllAttachmentDownloaded) break; + } + + if (!isAllAttachmentDownloaded) { + return; + } + _read = YES; [self saveWithTransaction:transaction];