mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Added tracking of active chats filter to chats filters strip.
This commit is contained in:
parent
f205952ff2
commit
bcd84518d1
3 changed files with 21 additions and 4 deletions
|
@ -667,7 +667,8 @@ Widget::Widget(
|
|||
rpl::single(0),
|
||||
[=](int h) { updateControlsGeometry(); },
|
||||
[=](FilterId id) { controller->setActiveChatsFilter(id); },
|
||||
Core::App().settings().chatFiltersHorizontalValue());
|
||||
Core::App().settings().chatFiltersHorizontalValue(),
|
||||
true);
|
||||
_chatFilters->stackUnder(_scroll);
|
||||
_chatFilters->resizeToWidth(width());
|
||||
updateControlsGeometry();
|
||||
|
|
|
@ -130,7 +130,8 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
|
|||
rpl::producer<int> multiSelectHeightValue,
|
||||
Fn<void(int)> setAddedTopScrollSkip,
|
||||
Fn<void(FilterId)> choose,
|
||||
rpl::producer<bool> additionalToggleOn) {
|
||||
rpl::producer<bool> additionalToggleOn,
|
||||
bool trackActiveChatsFilter) {
|
||||
const auto window = Core::App().findWindow(parent);
|
||||
const auto controller = window ? window->sessionController() : nullptr;
|
||||
|
||||
|
@ -265,7 +266,21 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
|
|||
applyFilter(filter);
|
||||
}
|
||||
}();
|
||||
slider->sectionActivated() | rpl::start_with_next([=](int index) {
|
||||
if (trackActiveChatsFilter) {
|
||||
controller->activeChatsFilter(
|
||||
) | rpl::start_with_next([=](FilterId id) {
|
||||
const auto &list = session->data().chatsFilters().list();
|
||||
for (auto i = 0; i < list.size(); ++i) {
|
||||
if (list[i].id() == id) {
|
||||
slider->setActiveSection(i);
|
||||
scrollToIndex(i, anim::type::normal);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, slider->lifetime());
|
||||
}
|
||||
slider->sectionActivated() | rpl::distinct_until_changed(
|
||||
) | rpl::start_with_next([=](int index) {
|
||||
const auto &filter = filterByIndex(index);
|
||||
state->lastFilterId = filter.id();
|
||||
scrollToIndex(index, anim::type::normal);
|
||||
|
|
|
@ -23,6 +23,7 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
|
|||
rpl::producer<int> multiSelectHeightValue,
|
||||
Fn<void(int)> setAddedTopScrollSkip,
|
||||
Fn<void(FilterId)> choose,
|
||||
rpl::producer<bool> additionalToggleOn = rpl::single(true));
|
||||
rpl::producer<bool> additionalToggleOn = rpl::single(true),
|
||||
bool trackActiveChatsFilter = false);
|
||||
|
||||
} // namespace Ui
|
||||
|
|
Loading…
Add table
Reference in a new issue