Fixed behavior to open section with scheduled messages at top.

This commit is contained in:
23rd 2024-04-08 04:11:52 +03:00
parent 84ce72ec7a
commit 94f1d23788
2 changed files with 10 additions and 4 deletions

View file

@ -58,11 +58,19 @@ namespace HistoryView {
ScheduledMemento::ScheduledMemento(not_null<History*> history) ScheduledMemento::ScheduledMemento(not_null<History*> history)
: _history(history) : _history(history)
, _forumTopic(nullptr) { , _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<Data::ForumTopic*> forumTopic) ScheduledMemento::ScheduledMemento(not_null<Data::ForumTopic*> forumTopic)
: _history(forumTopic->owningHistory()) : _history(forumTopic->owningHistory())
, _forumTopic(forumTopic) { , _forumTopic(forumTopic) {
const auto list = _history->owner().scheduledMessages().list(_forumTopic);
if (!list.ids.empty()) {
_list.setScrollTopState({ .item = { .fullId = list.ids.front() } });
}
} }
object_ptr<Window::SectionWidget> ScheduledMemento::createWidget( object_ptr<Window::SectionWidget> ScheduledMemento::createWidget(
@ -1154,9 +1162,7 @@ Context ScheduledWidget::listContext() {
} }
bool ScheduledWidget::listScrollTo(int top, bool syntetic) { bool ScheduledWidget::listScrollTo(int top, bool syntetic) {
top = (top == ScrollMax && syntetic) top = std::clamp(top, 0, _scroll->scrollTopMax());
? 0
: std::clamp(top, 0, _scroll->scrollTopMax());
if (_scroll->scrollTop() == top) { if (_scroll->scrollTop() == top) {
updateInnerVisibleArea(); updateInnerVisibleArea();
return false; return false;

View file

@ -280,7 +280,7 @@ private:
}; };
class ScheduledMemento : public Window::SectionMemento { class ScheduledMemento final : public Window::SectionMemento {
public: public:
ScheduledMemento(not_null<History*> history); ScheduledMemento(not_null<History*> history);
ScheduledMemento(not_null<Data::ForumTopic*> forumTopic); ScheduledMemento(not_null<Data::ForumTopic*> forumTopic);