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.
This commit is contained in:
John Preston 2017-08-25 16:33:55 +03:00
parent 4c604b34c1
commit 5a1d52f82e
1 changed files with 11 additions and 0 deletions

View File

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