From 1592f70a7c20cc265419256149825a85b134be90 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 12 Jan 2023 12:19:42 +0400 Subject: [PATCH] Respect trackUnreadMessages in history jumps. Fixes #25384. --- Telegram/SourceFiles/history/history_widget.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 0e521526f9..7f671aa769 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1960,7 +1960,9 @@ void HistoryWidget::applyCloudDraft(History *history) { } bool HistoryWidget::insideJumpToEndInsteadOfToUnread() const { - if (session().supportMode()) { + Expects(_history != nullptr); + + if (session().supportMode() || !_history->trackUnreadMessages()) { return true; } else if (!_historyInited) { return false; @@ -2193,6 +2195,10 @@ void HistoryWidget::showHistory( } else { _chooseForReport = nullptr; } + if (_showAtMsgId == ShowAtUnreadMsgId + && !_history->trackUnreadMessages()) { + _showAtMsgId = ShowAtTheEndMsgId; + } refreshTopBarActiveChat(); updateTopBarSelection(); @@ -2984,7 +2990,9 @@ void HistoryWidget::unreadCountUpdated() { } }); } else { - _cornerButtons.updateJumpDownVisibility(_history->isForum() + const auto hideCounter = _history->isForum() + || !_history->trackUnreadMessages(); + _cornerButtons.updateJumpDownVisibility(hideCounter ? 0 : _history->chatListBadgesState().unreadCounter); } @@ -5899,7 +5907,10 @@ std::optional HistoryWidget::cornerButtonsDownShown() { } const auto haveUnreadBelowBottom = [&](History *history) { - if (!_list || !history || history->unreadCount() <= 0) { + if (!_list + || !history + || history->unreadCount() <= 0 + || !history->trackUnreadMessages()) { return false; } const auto unread = history->firstUnreadMessage();