diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index a39adecefa..a53544ce8f 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -389,13 +389,13 @@ std::optional ListWidget::scrollTopForView( return top - std::max((available - height) / 2, 0); } -void ListWidget::animatedScrollTo( +void ListWidget::scrollTo( int scrollTop, Data::MessagePosition attachPosition, int delta, AnimatedScroll type) { _scrollToAnimation.stop(); - if (!delta || _items.empty()) { + if (!delta || _items.empty() || type == AnimatedScroll::None) { _delegate->listScrollTo(scrollTop); return; } diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.h b/Telegram/SourceFiles/history/view/history_view_list_widget.h index 5fa88ecde6..c0c3b3d706 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.h +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.h @@ -168,8 +168,9 @@ public: enum class AnimatedScroll { Full, Part, + None, }; - void animatedScrollTo( + void scrollTo( int scrollTop, Data::MessagePosition attachPosition, int delta, diff --git a/Telegram/SourceFiles/history/view/history_view_pinned_section.cpp b/Telegram/SourceFiles/history/view/history_view_pinned_section.cpp index b049bc262e..d6c6ac3ad5 100644 --- a/Telegram/SourceFiles/history/view/history_view_pinned_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_pinned_section.cpp @@ -178,7 +178,10 @@ void PinnedWidget::showAtPosition( bool PinnedWidget::showAtPositionNow( Data::MessagePosition position, - HistoryItem *originItem) { + HistoryItem *originItem, + anim::type animated) { + using AnimatedScroll = HistoryView::ListWidget::AnimatedScroll; + const auto item = position.fullId ? _history->owner().message(position.fullId) : nullptr; @@ -189,13 +192,16 @@ bool PinnedWidget::showAtPositionNow( const auto fullDelta = (wanted - currentScrollTop); const auto limit = _scroll->height(); const auto scrollDelta = snap(fullDelta, -limit, limit); - _inner->animatedScrollTo( + const auto type = (animated == anim::type::instant) + ? AnimatedScroll::None + : (std::abs(fullDelta) > limit) + ? AnimatedScroll::Part + : AnimatedScroll::Full; + _inner->scrollTo( wanted, use, scrollDelta, - (std::abs(fullDelta) > limit - ? HistoryView::ListWidget::AnimatedScroll::Part - : HistoryView::ListWidget::AnimatedScroll::Full)); + type); if (use != Data::MaxMessagePosition && use != Data::UnreadMessagePosition) { _inner->highlightMessage(use.fullId); @@ -356,7 +362,7 @@ void PinnedWidget::restoreState(not_null memento) { .date = TimeId(0), }; _inner->showAroundPosition(position, [=] { - return showAtPositionNow(position, nullptr); + return showAtPositionNow(position, nullptr, anim::type::instant); }); } } diff --git a/Telegram/SourceFiles/history/view/history_view_pinned_section.h b/Telegram/SourceFiles/history/view/history_view_pinned_section.h index 09935471c4..c5eebcf5e5 100644 --- a/Telegram/SourceFiles/history/view/history_view_pinned_section.h +++ b/Telegram/SourceFiles/history/view/history_view_pinned_section.h @@ -117,7 +117,8 @@ private: HistoryItem *originItem = nullptr); bool showAtPositionNow( Data::MessagePosition position, - HistoryItem *originItem); + HistoryItem *originItem, + anim::type animated = anim::type::normal); void setupScrollDownButton(); void scrollDownClicked(); diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index 7763d2acb7..17947323e8 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -1169,7 +1169,9 @@ void RepliesWidget::showAtPosition( bool RepliesWidget::showAtPositionNow( Data::MessagePosition position, - HistoryItem *originItem) { + HistoryItem *originItem, + anim::type animated) { + using AnimatedScroll = HistoryView::ListWidget::AnimatedScroll; const auto item = position.fullId ? _history->owner().message(position.fullId) : nullptr; @@ -1183,13 +1185,16 @@ bool RepliesWidget::showAtPositionNow( const auto fullDelta = (wanted - currentScrollTop); const auto limit = _scroll->height(); const auto scrollDelta = snap(fullDelta, -limit, limit); - _inner->animatedScrollTo( + const auto type = (animated == anim::type::instant) + ? AnimatedScroll::None + : (std::abs(fullDelta) > limit) + ? AnimatedScroll::Part + : AnimatedScroll::Full; + _inner->scrollTo( wanted, use, scrollDelta, - (std::abs(fullDelta) > limit - ? HistoryView::ListWidget::AnimatedScroll::Part - : HistoryView::ListWidget::AnimatedScroll::Full)); + type); if (use != Data::MaxMessagePosition && use != Data::UnreadMessagePosition) { _inner->highlightMessage(use.fullId); diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.h b/Telegram/SourceFiles/history/view/history_view_replies_section.h index 127c18dc4e..e031369d5c 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.h +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.h @@ -150,7 +150,8 @@ private: HistoryItem *originItem = nullptr); bool showAtPositionNow( Data::MessagePosition position, - HistoryItem *originItem); + HistoryItem *originItem, + anim::type animated = anim::type::normal); void finishSending(); void setupComposeControls(); diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index d18fdc0c9b..66bc5bd48b 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -802,7 +802,7 @@ bool ScheduledWidget::showAtPositionNow(Data::MessagePosition position) { const auto fullDelta = (wanted - currentScrollTop); const auto limit = _scroll->height(); const auto scrollDelta = snap(fullDelta, -limit, limit); - _inner->animatedScrollTo( + _inner->scrollTo( wanted, position, scrollDelta,