Optimized height refresh of main list on receiving chats filters.

This commit is contained in:
23rd 2024-11-20 06:15:35 +03:00
parent e3465da979
commit 632abd2225

View file

@ -624,8 +624,14 @@ bool ChatFilters::applyChange(ChatFilter &filter, ChatFilter &&updated) {
}
const auto wasFilter = std::move(filter);
filter = std::move(updated);
auto entryToRefreshHeight = (Dialogs::Entry*)(nullptr);
if (rulesChanged) {
const auto filterList = _owner->chatsFilters().chatsList(id);
const auto tagsExistence = [&](not_null<Dialogs::Row*> row) {
return entryToRefreshHeight
? false
: row->entry()->hasChatsFilterTags(0);
};
const auto feedHistory = [&](not_null<History*> history) {
const auto now = filter.contains(history);
const auto was = wasFilter.contains(history);
@ -640,7 +646,11 @@ bool ChatFilters::applyChange(ChatFilter &filter, ChatFilter &&updated) {
const auto feedList = [&](not_null<const Dialogs::MainList*> list) {
for (const auto &entry : *list->indexed()) {
if (const auto history = entry->history()) {
const auto wasTags = tagsExistence(entry);
feedHistory(history);
if (wasTags != tagsExistence(entry)) {
entryToRefreshHeight = entry->entry();
}
}
}
};
@ -662,6 +672,10 @@ bool ChatFilters::applyChange(ChatFilter &filter, ChatFilter &&updated) {
if (chatlistChanged) {
_isChatlistChanged.fire_copy(id);
}
if (entryToRefreshHeight) {
// Trigger a full refresh of height for the main list.
entryToRefreshHeight->updateChatListEntryHeight();
}
return listUpdated;
}