From c3463dec63eb17081ddaba71910fbdd2c9026354 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 24 Feb 2020 14:53:38 +0400 Subject: [PATCH] Force zero unread count if read till end. --- Telegram/SourceFiles/data/data_histories.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Telegram/SourceFiles/data/data_histories.cpp b/Telegram/SourceFiles/data/data_histories.cpp index 434a8b33f5..ee3da94216 100644 --- a/Telegram/SourceFiles/data/data_histories.cpp +++ b/Telegram/SourceFiles/data/data_histories.cpp @@ -135,6 +135,17 @@ void Histories::readInboxTill( bool force) { Expects(IsServerMsgId(tillId) || (!tillId && !force)); + const auto syncGuard = gsl::finally([&] { + if (history->unreadCount() > 0) { + if (const auto last = history->lastServerMessage()) { + if (last->id == tillId) { + history->setUnreadCount(0); + history->updateChatListEntry(); + } + } + } + }); + history->session().notifications().clearIncomingFromHistory(history); const auto needsRequest = history->readInboxTillNeedsRequest(tillId);