Added ability to go to top of chats list by clicking on selected filter.

This commit is contained in:
23rd 2024-11-17 13:43:19 +03:00
parent 67bbdbfc70
commit db2e45c56e
2 changed files with 9 additions and 4 deletions

View file

@ -1328,6 +1328,7 @@ void Widget::toggleFiltersMenu(bool enabled) {
_chatFilters.get(),
&session(),
[this](FilterId id) {
_scroll->scrollToY(0);
if (controller()->activeChatsFilterCurrent() != id) {
controller()->setActiveChatsFilter(id);
}

View file

@ -381,14 +381,18 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
state->reorder->finishReordering();
}, slider->lifetime());
}
slider->sectionActivated() | rpl::distinct_until_changed(
) | rpl::start_with_next([=](int index) {
rpl::single(-1) | rpl::then(
slider->sectionActivated()
) | rpl::combine_previous(
) | rpl::start_with_next([=](int was, int index) {
if (slider->reordering()) {
return;
}
const auto &filter = filterByIndex(index);
state->lastFilterId = filter.id();
scrollToIndex(index, anim::type::normal);
if (was != index) {
state->lastFilterId = filter.id();
scrollToIndex(index, anim::type::normal);
}
applyFilter(filter);
}, wrap->lifetime());
slider->contextMenuRequested() | rpl::start_with_next([=](int index) {