From 5a1d52f82e5fb3cb1862335ac0729585897d569a Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 25 Aug 2017 16:33:55 +0300 Subject: [PATCH] Fix unread mentions navigation issues. When the unread bar was destroyed we first jumped to the bottom of the history by updateHistoryGeometry() and only after that animated scroll to the desired message started. The last messages were always painted (and marked as read) in that case. --- Telegram/SourceFiles/history/history_widget.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 2293c3207..0eba2e2c2 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -884,6 +884,9 @@ void HistoryWidget::scrollToCurrentVoiceMessage(FullMsgId fromId, FullMsgId toId void HistoryWidget::animatedScrollToItem(MsgId msgId) { Expects(_history != nullptr); + if (hasPendingResizedItems()) { + updateListSize(); + } auto to = App::histItemById(_channel, msgId); if (_list->itemTop(to) < 0) { @@ -896,6 +899,9 @@ void HistoryWidget::animatedScrollToItem(MsgId msgId) { void HistoryWidget::animatedScrollToY(int scrollTo, HistoryItem *attachTo) { Expects(_history != nullptr); + if (hasPendingResizedItems()) { + updateListSize(); + } // Attach our scroll animation to some item. auto itemTop = _list->itemTop(attachTo); @@ -920,6 +926,11 @@ void HistoryWidget::animatedScrollToY(int scrollTo, HistoryItem *attachTo) { scrollTop = scrollTo + maxAnimatedDelta; synteticScrollToY(scrollTop); transition = anim::easeOutCubic; + } else { + // In local showHistory() we forget current scroll state, + // so we need to restore it synchronously, otherwise we may + // jump to the bottom of history in some updateHistoryGeometry() call. + synteticScrollToY(scrollTop); } _scrollToAnimation.start([this, itemId = attachTo->fullId()] { scrollToAnimationCallback(itemId); }, scrollTop - itemTop, scrollTo - itemTop, st::slideDuration, anim::sineInOut); }