From 0d58b32914f1af557f0021cb082ca403318583f3 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 20 Nov 2024 02:32:23 +0300 Subject: [PATCH] Added ability to recount height of dialog rows by chats filter id. --- .../SourceFiles/dialogs/dialogs_inner_widget.cpp | 6 +++--- Telegram/SourceFiles/dialogs/dialogs_list.cpp | 6 +++--- Telegram/SourceFiles/dialogs/dialogs_row.cpp | 12 ++++++++++-- Telegram/SourceFiles/dialogs/dialogs_row.h | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index f587dab2b..585f72aa8 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -408,7 +408,7 @@ bool InnerWidget::updateEntryHeight(not_null entry) { result.top = top; } if (result.row->key().entry() == entry) { - result.row->recountHeight(_narrowRatio); + result.row->recountHeight(_narrowRatio, _filterId); changing = true; top = result.top; } @@ -2812,7 +2812,7 @@ void InnerWidget::applySearchState(SearchState state) { end(results)); for (const auto e = end(_filterResults); i != e; ++i) { i->top = top; - i->row->recountHeight(_narrowRatio); + i->row->recountHeight(_narrowRatio, _filterId); top += i->row->height(); } }; @@ -2885,7 +2885,7 @@ void InnerWidget::appendToFiltered(Key key) { } } auto row = std::make_unique(key, 0, 0); - row->recountHeight(_narrowRatio); + row->recountHeight(_narrowRatio, _filterId); const auto &[i, ok] = _filterResultsGlobal.emplace(key, std::move(row)); const auto height = filteredHeight(); _filterResults.emplace_back(i->second.get()); diff --git a/Telegram/SourceFiles/dialogs/dialogs_list.cpp b/Telegram/SourceFiles/dialogs/dialogs_list.cpp index 362f8b857..ce6a72462 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_list.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_list.cpp @@ -32,7 +32,7 @@ not_null List::addToEnd(Key key) { key, std::make_unique(key, _rows.size(), height()) ).first->second.get(); - result->recountHeight(_narrowRatio); + result->recountHeight(_narrowRatio, _filterId); _rows.emplace_back(result); if (_sortMode == SortMode::Date) { adjustByDate(result); @@ -112,7 +112,7 @@ bool List::updateHeight(Key key, float64 narrowRatio) { const auto index = row->index(); auto top = row->top(); const auto was = row->height(); - row->recountHeight(narrowRatio); + row->recountHeight(narrowRatio, _filterId); if (row->height() == was) { return false; } @@ -129,7 +129,7 @@ bool List::updateHeights(float64 narrowRatio) { auto top = 0; for (const auto &row : _rows) { row->_top = top; - row->recountHeight(narrowRatio); + row->recountHeight(narrowRatio, _filterId); top += row->height(); } return (height() != was); diff --git a/Telegram/SourceFiles/dialogs/dialogs_row.cpp b/Telegram/SourceFiles/dialogs/dialogs_row.cpp index 5a0730f86..8f974aa09 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_row.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_row.cpp @@ -316,11 +316,19 @@ Row::~Row() { clearTopicJumpRipple(); } -void Row::recountHeight(float64 narrowRatio) { +void Row::recountHeight(float64 narrowRatio, FilterId filterId) { if (const auto history = _id.history()) { + const auto hasTags = _id.entry()->hasChatsFilterTags(filterId); _height = history->isForum() ? anim::interpolate( - st::forumDialogRow.height, + hasTags + ? st::taggedForumDialogRow.height + : st::forumDialogRow.height, + st::defaultDialogRow.height, + narrowRatio) + : hasTags + ? anim::interpolate( + st::taggedDialogRow.height, st::defaultDialogRow.height, narrowRatio) : st::defaultDialogRow.height; diff --git a/Telegram/SourceFiles/dialogs/dialogs_row.h b/Telegram/SourceFiles/dialogs/dialogs_row.h index a4ddde404..b5181ba66 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_row.h +++ b/Telegram/SourceFiles/dialogs/dialogs_row.h @@ -94,7 +94,7 @@ public: return _height; } - void recountHeight(float64 narrowRatio); + void recountHeight(float64 narrowRatio, FilterId filterId); void updateCornerBadgeShown( not_null peer,