2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-05 00:46:08 +00:00

Added api support for enabled tags of chats filters.

This commit is contained in:
23rd
2024-11-20 10:49:57 +03:00
parent e314c68a56
commit ba082081b3
5 changed files with 72 additions and 23 deletions

View File

@@ -297,6 +297,47 @@ InnerWidget::InnerWidget(
refreshWithCollapsedRows();
}, lifetime());
session().data().chatsFilters().tagsEnabledValue(
) | rpl::distinct_until_changed() | rpl::start_with_next([=](bool tags) {
_handleChatListEntryTagRefreshesLifetime.destroy();
if (_shownList->updateHeights(_narrowRatio)) {
refresh();
}
if (!tags) {
return;
}
using Event = Data::Session::ChatListEntryRefresh;
session().data().chatListEntryRefreshes(
) | rpl::filter([=](const Event &event) {
if (_waitingAllChatListEntryRefreshesForTags) {
return false;
}
if (event.existenceChanged) {
if (event.key.entry()->inChatList(_filterId)) {
_waitingAllChatListEntryRefreshesForTags = true;
return true;
}
}
return false;
}) | rpl::start_with_next([=](const Event &event) {
Ui::PostponeCall(crl::guard(this, [=] {
_waitingAllChatListEntryRefreshesForTags = false;
if (_shownList->updateHeights(_narrowRatio)) {
refresh();
}
}));
}, _handleChatListEntryTagRefreshesLifetime);
session().data().chatsFilters().tagColorChanged(
) | rpl::start_with_next([=](FilterId filterId) {
const auto it = _chatsFilterTags.find(filterId);
if (it != _chatsFilterTags.end()) {
_chatsFilterTags.erase(it);
update();
}
}, _handleChatListEntryTagRefreshesLifetime);
}, lifetime());
session().settings().archiveInMainMenuChanges(
) | rpl::start_with_next([=] {
refresh();
@@ -2260,27 +2301,6 @@ void InnerWidget::handleChatListEntryRefreshes() {
std::abs(from - to) + event.moved.height);
}
}, lifetime());
session().data().chatListEntryRefreshes(
) | rpl::filter([=](const Event &event) {
if (_waitingAllChatListEntryRefreshesForTags) {
return false;
}
if (event.existenceChanged) {
if (event.key.entry()->inChatList(_filterId)) {
_waitingAllChatListEntryRefreshesForTags = true;
return true;
}
}
return false;
}) | rpl::start_with_next([=](const Event &event) {
Ui::PostponeCall(crl::guard(this, [=] {
_waitingAllChatListEntryRefreshesForTags = false;
if (_shownList->updateHeights(_narrowRatio)) {
refresh();
}
}));
}, lifetime());
}
void InnerWidget::repaintCollapsedFolderRow(not_null<Data::Folder*> folder) {