Fix restoring scroll state with a pinned bar.

This commit is contained in:
John Preston 2020-11-02 11:44:05 +03:00
parent 07f07c5eeb
commit a21b6d7416
2 changed files with 6 additions and 1 deletions

View file

@ -3230,6 +3230,9 @@ void HistoryWidget::doneShow() {
} else {
handlePendingHistoryUpdate();
}
// If we show pinned bar here, we don't want it to change the
// calculated and prepared scrollTop of the messages history.
_preserveScrollTop = true;
preloadHistoryIfNeeded();
updatePinnedViewer();
if (_pinnedBar) {
@ -3237,6 +3240,7 @@ void HistoryWidget::doneShow() {
}
checkHistoryActivation();
App::wnd()->setInnerFocus();
_preserveScrollTop = false;
}
void HistoryWidget::finishAnimating() {
@ -5330,7 +5334,7 @@ void HistoryWidget::checkPinnedBarState() {
_pinnedBarHeight = 0;
_pinnedBar->heightValue(
) | rpl::start_with_next([=](int height) {
_topDelta = (height - _pinnedBarHeight);
_topDelta = _preserveScrollTop ? 0 : (height - _pinnedBarHeight);
_pinnedBarHeight = height;
updateHistoryGeometry();
updateControlsGeometry();

View file

@ -599,6 +599,7 @@ private:
std::unique_ptr<HistoryView::PinnedTracker> _pinnedTracker;
std::unique_ptr<Ui::PinnedBar> _pinnedBar;
int _pinnedBarHeight = 0;
bool _preserveScrollTop = false;
FullMsgId _pinnedClickedId;
std::optional<FullMsgId> _minPinnedId;