From 94f1d23788545edecafad311de029f29475ff02b Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 8 Apr 2024 04:11:52 +0300 Subject: [PATCH] Fixed behavior to open section with scheduled messages at top. --- .../history/view/history_view_scheduled_section.cpp | 12 +++++++++--- .../history/view/history_view_scheduled_section.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index 188d11338..6c989fd1e 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -58,11 +58,19 @@ namespace HistoryView { ScheduledMemento::ScheduledMemento(not_null history) : _history(history) , _forumTopic(nullptr) { + const auto list = _history->owner().scheduledMessages().list(_history); + if (!list.ids.empty()) { + _list.setScrollTopState({ .item = { .fullId = list.ids.front() } }); + } } ScheduledMemento::ScheduledMemento(not_null forumTopic) : _history(forumTopic->owningHistory()) , _forumTopic(forumTopic) { + const auto list = _history->owner().scheduledMessages().list(_forumTopic); + if (!list.ids.empty()) { + _list.setScrollTopState({ .item = { .fullId = list.ids.front() } }); + } } object_ptr ScheduledMemento::createWidget( @@ -1154,9 +1162,7 @@ Context ScheduledWidget::listContext() { } bool ScheduledWidget::listScrollTo(int top, bool syntetic) { - top = (top == ScrollMax && syntetic) - ? 0 - : std::clamp(top, 0, _scroll->scrollTopMax()); + top = std::clamp(top, 0, _scroll->scrollTopMax()); if (_scroll->scrollTop() == top) { updateInnerVisibleArea(); return false; diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.h b/Telegram/SourceFiles/history/view/history_view_scheduled_section.h index 850e56bb7..43702688f 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.h +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.h @@ -280,7 +280,7 @@ private: }; -class ScheduledMemento : public Window::SectionMemento { +class ScheduledMemento final : public Window::SectionMemento { public: ScheduledMemento(not_null history); ScheduledMemento(not_null forumTopic);