From bd7e9b5943a9ff779e4c66e1ede0aca4eaa189d9 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Tue, 20 Jul 2021 11:46:02 +1000 Subject: [PATCH] add comment --- Session/Conversations/ConversationVC.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Session/Conversations/ConversationVC.swift b/Session/Conversations/ConversationVC.swift index 45cf5b7ce..baa5ec147 100644 --- a/Session/Conversations/ConversationVC.swift +++ b/Session/Conversations/ConversationVC.swift @@ -222,6 +222,10 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat Storage.read { transaction in unreadCount = self.thread.unreadMessageCount(transaction: transaction) } + // When the unread message count is more than the number of a page of viewItems, + // the screen will scroll to bottom instead of the correct first unread message. + // The unreadIndicatorIndex is calculated during loading the viewItems, it is + // supposed to be accurate. DispatchQueue.main.async { let unreadIndicatorIndex = self.viewModel.viewState.unreadIndicatorIndex?.intValue ?? (self.viewItems.count - self.unreadViewItems.count) if unreadCount > 0, let viewItem = self.viewItems[ifValid: unreadIndicatorIndex], let interactionID = viewItem.interaction.uniqueId {