Optimized height refresh of chats list for chat filters with rules.

This commit is contained in:
23rd 2024-11-20 07:51:03 +03:00
parent 889fcb3939
commit e314c68a56
2 changed files with 23 additions and 0 deletions

View file

@ -2260,6 +2260,27 @@ 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) {

View file

@ -557,6 +557,8 @@ private:
base::flat_map<FilterId, int> _chatsFilterScrollStates;
std::unordered_map<FilterId, QImage> _chatsFilterTags;
bool _waitingAllChatListEntryRefreshesForTags = false;
Fn<void()> _loadMoreCallback;
Fn<void()> _loadMoreFilteredCallback;
rpl::event_stream<> _listBottomReached;