From 33c0c79593d142bf9454738ababf8124ae3eaad8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 2 Dec 2022 21:29:51 +0400 Subject: [PATCH] Correct unread counter after first topic open. --- Telegram/SourceFiles/data/data_replies_list.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/data/data_replies_list.cpp b/Telegram/SourceFiles/data/data_replies_list.cpp index 492db196ed..dedcb57f27 100644 --- a/Telegram/SourceFiles/data/data_replies_list.cpp +++ b/Telegram/SourceFiles/data/data_replies_list.cpp @@ -860,7 +860,13 @@ std::optional RepliesList::computeUnreadCountLocally( MsgId afterId) const { Expects(afterId >= _inboxReadTillId); - const auto wasUnreadCountAfter = _unreadCount.current(); + const auto currentUnreadCountAfter = _unreadCount.current(); + const auto startingMarkingAsRead = (currentUnreadCountAfter == 0) + && (_inboxReadTillId == 1) + && (afterId > 1); + const auto wasUnreadCountAfter = startingMarkingAsRead + ? _fullCount.current().value_or(0) + : currentUnreadCountAfter; const auto readTillId = std::max(afterId, _rootId); const auto wasReadTillId = _inboxReadTillId; const auto backLoaded = (_skippedBefore == 0);