mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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),
|
rpl::single(0),
|
||||||
[=](int h) { updateControlsGeometry(); },
|
[=](int h) { updateControlsGeometry(); },
|
||||||
[=](FilterId id) { controller->setActiveChatsFilter(id); },
|
[=](FilterId id) { controller->setActiveChatsFilter(id); },
|
||||||
Core::App().settings().chatFiltersHorizontalValue());
|
Core::App().settings().chatFiltersHorizontalValue(),
|
||||||
|
true);
|
||||||
_chatFilters->stackUnder(_scroll);
|
_chatFilters->stackUnder(_scroll);
|
||||||
_chatFilters->resizeToWidth(width());
|
_chatFilters->resizeToWidth(width());
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
|
|
|
@ -130,7 +130,8 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
|
||||||
rpl::producer<int> multiSelectHeightValue,
|
rpl::producer<int> multiSelectHeightValue,
|
||||||
Fn<void(int)> setAddedTopScrollSkip,
|
Fn<void(int)> setAddedTopScrollSkip,
|
||||||
Fn<void(FilterId)> choose,
|
Fn<void(FilterId)> choose,
|
||||||
rpl::producer<bool> additionalToggleOn) {
|
rpl::producer<bool> additionalToggleOn,
|
||||||
|
bool trackActiveChatsFilter) {
|
||||||
const auto window = Core::App().findWindow(parent);
|
const auto window = Core::App().findWindow(parent);
|
||||||
const auto controller = window ? window->sessionController() : nullptr;
|
const auto controller = window ? window->sessionController() : nullptr;
|
||||||
|
|
||||||
|
@ -265,7 +266,21 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
|
||||||
applyFilter(filter);
|
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);
|
const auto &filter = filterByIndex(index);
|
||||||
state->lastFilterId = filter.id();
|
state->lastFilterId = filter.id();
|
||||||
scrollToIndex(index, anim::type::normal);
|
scrollToIndex(index, anim::type::normal);
|
||||||
|
|
|
@ -23,6 +23,7 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
|
||||||
rpl::producer<int> multiSelectHeightValue,
|
rpl::producer<int> multiSelectHeightValue,
|
||||||
Fn<void(int)> setAddedTopScrollSkip,
|
Fn<void(int)> setAddedTopScrollSkip,
|
||||||
Fn<void(FilterId)> choose,
|
Fn<void(FilterId)> choose,
|
||||||
rpl::producer<bool> additionalToggleOn = rpl::single(true));
|
rpl::producer<bool> additionalToggleOn = rpl::single(true),
|
||||||
|
bool trackActiveChatsFilter = false);
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
Loading…
Add table
Reference in a new issue