Fix scroll in return to a channel I'm not in.

This commit is contained in:
John Preston 2023-01-21 21:24:54 +04:00
parent a6484e6131
commit fcfacf1f9d
2 changed files with 11 additions and 2 deletions

View file

@ -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)

View file

@ -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();