From b79de0cf328842342e460f91c571feaefd7fea85 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Fri, 8 Sep 2023 11:04:47 +1000 Subject: [PATCH] Fixed an issue where call messages wouldn't get marked as read when the last message in a conversation --- Session/Conversations/ConversationVC.swift | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Session/Conversations/ConversationVC.swift b/Session/Conversations/ConversationVC.swift index f5f1ded92..e6e60e648 100644 --- a/Session/Conversations/ConversationVC.swift +++ b/Session/Conversations/ConversationVC.swift @@ -1951,14 +1951,22 @@ final class ConversationVC: BaseVC, SessionUtilRespondingViewController, Convers .sorted() .filter({ $0.section == messagesSection }) .compactMap({ indexPath -> (frame: CGRect, cellViewModel: MessageViewModel)? in - guard let cell: VisibleMessageCell = tableView.cellForRow(at: indexPath) as? VisibleMessageCell else { - return nil - } + guard let cell: UITableViewCell = tableView.cellForRow(at: indexPath) else { return nil } - return ( - view.convert(cell.frame, from: tableView), - self.viewModel.interactionData[indexPath.section].elements[indexPath.row] - ) + switch cell { + case is VisibleMessageCell, is CallMessageCell, is InfoMessageCell: + return ( + view.convert(cell.frame, from: tableView), + self.viewModel.interactionData[indexPath.section].elements[indexPath.row] + ) + + case is TypingIndicatorCell, is DateHeaderCell, is UnreadMarkerCell: + return nil + + default: + SNLog("[ConversationVC] Warning: Processing unhandled cell type when marking as read, this could result in intermittent failures") + return nil + } }) // Exclude messages that are partially off the bottom of the screen .filter({ $0.frame.maxY <= tableVisualBottom })