mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Optimized height refresh of main list on receiving chats filters.
This commit is contained in:
parent
e3465da979
commit
632abd2225
1 changed files with 14 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue