Don't resubscribe on folder strip rebuild.

This commit is contained in:
John Preston 2024-11-17 23:09:42 +04:00
parent 39780f49bf
commit c080bd4c4d

View file

@ -41,7 +41,7 @@ namespace {
struct State final {
Ui::Animations::Simple animation;
std::optional<FilterId> lastFilterId = std::nullopt;
rpl::lifetime unreadLifetime;
rpl::lifetime rebuildLifetime;
base::unique_qptr<Ui::PopupMenu> menu;
Api::RemoveComplexChatFilter removeApi;
@ -293,6 +293,7 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
if ((list.size() <= 1 && !slider->width()) || state->ignoreRefresh) {
return;
}
state->rebuildLifetime.destroy();
auto sections = ranges::views::all(
list
) | ranges::views::transform([](const Data::ChatFilter &filter) {
@ -312,7 +313,7 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
: premiumFrom);
slider->lockedClicked() | rpl::start_with_next([=] {
controller->show(Box(FiltersLimitBox, session, std::nullopt));
}, slider->lifetime());
}, state->rebuildLifetime);
if (state->reorder) {
state->reorder->cancel();
state->reorder->clearPinnedIntervals();
@ -326,7 +327,6 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
}
if (trackActiveFilterAndUnreadAndReorder) {
auto includeMuted = Data::IncludeMutedCounterFoldersValue();
state->unreadLifetime.destroy();
for (auto i = 0; i < list.size(); i++) {
rpl::combine(
Data::UnreadStateValue(session, list[i].id()),
@ -340,7 +340,7 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
const auto isMuted = includeMuted && (count == muted);
slider->setUnreadCount(i, count, isMuted);
slider->fitWidthToSections();
}, state->unreadLifetime);
}, state->rebuildLifetime);
}
}
[&] {
@ -379,7 +379,7 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
}
}
state->reorder->finishReordering();
}, slider->lifetime());
}, state->rebuildLifetime);
}
rpl::single(-1) | rpl::then(
slider->sectionActivated()
@ -394,7 +394,7 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
scrollToIndex(index, anim::type::normal);
}
applyFilter(filter);
}, wrap->lifetime());
}, state->rebuildLifetime);
slider->contextMenuRequested() | rpl::start_with_next([=](int index) {
if (trackActiveFilterAndUnreadAndReorder) {
ShowMenu(wrap, controller, state, index);
@ -406,7 +406,7 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
slider->activeSection(),
[=](int i) { slider->setActiveSection(i); });
}
}, slider->lifetime());
}, state->rebuildLifetime);
wrap->toggle((list.size() > 1), anim::type::instant);
if (state->reorder) {