diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index ca34da436..f10a21d77 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -2189,7 +2189,8 @@ void HistoryWidget::showHistory( _chooseForReport = nullptr; } if (_showAtMsgId == ShowAtUnreadMsgId - && !_history->trackUnreadMessages()) { + && !_history->trackUnreadMessages() + && !hasSavedScroll()) { _showAtMsgId = ShowAtTheEndMsgId; } refreshTopBarActiveChat(); @@ -5394,8 +5395,15 @@ MsgId HistoryWidget::replyToId() const { return _replyToId ? _replyToId : (_kbReplyTo ? _kbReplyTo->id : 0); } +bool HistoryWidget::hasSavedScroll() const { + Expects(_history != nullptr); + + return _history->scrollTopItem + || (_migrated && _migrated->scrollTopItem); +} + int HistoryWidget::countInitialScrollTop() { - if (_history->scrollTopItem || (_migrated && _migrated->scrollTopItem)) { + if (hasSavedScroll()) { return _list->historyScrollTop(); } else if (_showAtMsgId && (IsServerMsgId(_showAtMsgId) diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index a00857f60..f3281a6f0 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -573,6 +573,7 @@ private: // when scroll position or scroll area size changed this method // updates the boundings of the visible area in HistoryInner + [[nodiscard]] bool hasSavedScroll() const; void visibleAreaUpdated(); int countInitialScrollTop(); int countAutomaticScrollTop();