From c7b3c95dc65db513c0a98a0c7868a5c8ae61046c Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 1 Feb 2023 22:01:00 +0400 Subject: [PATCH] Fix root view pinned bar glitch in comments. --- .../view/history_view_replies_section.cpp | 29 ++++++++++++------- .../view/history_view_replies_section.h | 1 + 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index aceb70c2c4..315be0e432 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -2259,14 +2259,16 @@ void RepliesWidget::updatePinnedVisibility() { void RepliesWidget::setPinnedVisibility(bool shown) { if (animatingShow()) { return; - } else if (!_topic && !_rootViewInited) { - const auto height = shown ? st::historyReplyHeight : 0; - if (const auto delta = height - _rootViewHeight) { - _rootViewHeight = height; - if (_scroll->scrollTop() == _scroll->scrollTopMax()) { - setGeometryWithTopMoved(geometry(), delta); - } else { - updateControlsGeometry(); + } else if (!_topic) { + if (!_rootViewInitScheduled) { + const auto height = shown ? st::historyReplyHeight : 0; + if (const auto delta = height - _rootViewHeight) { + _rootViewHeight = height; + if (_scroll->scrollTop() == _scroll->scrollTopMax()) { + setGeometryWithTopMoved(geometry(), delta); + } else { + updateControlsGeometry(); + } } } if (shown) { @@ -2275,8 +2277,15 @@ void RepliesWidget::setPinnedVisibility(bool shown) { _rootView->hide(); } _rootVisible = shown; - _rootView->finishAnimating(); - _rootViewInited = true; + if (!_rootViewInited) { + _rootView->finishAnimating(); + if (!_rootViewInitScheduled) { + _rootViewInitScheduled = true; + InvokeQueued(this, [=] { + _rootViewInited = true; + }); + } + } } else { _rootVisible = shown; } diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.h b/Telegram/SourceFiles/history/view/history_view_replies_section.h index 8376d80441..0f8d2e0c10 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.h +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.h @@ -340,6 +340,7 @@ private: std::unique_ptr _rootView; int _rootViewHeight = 0; bool _rootViewInited = false; + bool _rootViewInitScheduled = false; rpl::variable _rootVisible = false; std::unique_ptr _scroll;