diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 9baed5c6c..129eda165 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -547,6 +547,10 @@ rpl::producer PeerListBox::multiSelectHeightValue() const { return _select ? _select->heightValue() : rpl::single(0); } +void PeerListBox::setIgnoreHiddenRowsOnSearch(bool value) { + content()->setIgnoreHiddenRowsOnSearch(value); +} + PeerListRow::PeerListRow(not_null peer) : PeerListRow(peer, peer->id.value) { } @@ -1389,10 +1393,12 @@ int PeerListContent::labelHeight() const { void PeerListContent::refreshRows() { if (!_hiddenRows.empty()) { - _filterResults.clear(); - for (const auto &row : _rows) { - if (!row->hidden()) { - _filterResults.push_back(row.get()); + if (!_ignoreHiddenRowsOnSearch || _normalizedSearchQuery.isEmpty()) { + _filterResults.clear(); + for (const auto &row : _rows) { + if (!row->hidden()) { + _filterResults.push_back(row.get()); + } } } } @@ -2057,10 +2063,13 @@ void PeerListContent::checkScrollForPreload() { void PeerListContent::searchQueryChanged(QString query) { const auto searchWordsList = TextUtilities::PrepareSearchWords(query); const auto normalizedQuery = searchWordsList.join(' '); + if (_ignoreHiddenRowsOnSearch && !normalizedQuery.isEmpty()) { + _filterResults.clear(); + } if (_normalizedSearchQuery != normalizedQuery) { setSearchQuery(query, normalizedQuery); if (_controller->searchInLocal() && !searchWordsList.isEmpty()) { - Assert(_hiddenRows.empty()); + Assert(_hiddenRows.empty() || _ignoreHiddenRowsOnSearch); auto minimalList = (const std::vector>*)nullptr; for (const auto &searchWord : searchWordsList) { @@ -2196,6 +2205,10 @@ void PeerListContent::dragLeft() { clearSelection(); } +void PeerListContent::setIgnoreHiddenRowsOnSearch(bool value) { + _ignoreHiddenRowsOnSearch = value; +} + void PeerListContent::visibleTopBottomUpdated( int visibleTop, int visibleBottom) { diff --git a/Telegram/SourceFiles/boxes/peer_list_box.h b/Telegram/SourceFiles/boxes/peer_list_box.h index 658eb4f31..31b8f348a 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.h +++ b/Telegram/SourceFiles/boxes/peer_list_box.h @@ -658,6 +658,8 @@ public: PeerListRowId updateFromParentDrag(QPoint globalPosition); void dragLeft(); + void setIgnoreHiddenRowsOnSearch(bool value); + // Interface for the controller. void appendRow(std::unique_ptr row); void appendSearchRow(std::unique_ptr row); @@ -879,6 +881,7 @@ private: int _aboveHeight = 0; int _belowHeight = 0; bool _hideEmpty = false; + bool _ignoreHiddenRowsOnSearch = false; object_ptr _aboveWidget = { nullptr }; object_ptr _aboveSearchWidget = { nullptr }; object_ptr _belowWidget = { nullptr }; @@ -1104,6 +1107,8 @@ public: [[nodiscard]] std::vector> collectSelectedRows(); [[nodiscard]] rpl::producer multiSelectHeightValue() const; + void setIgnoreHiddenRowsOnSearch(bool value); + void peerListSetTitle(rpl::producer title) override { setTitle(std::move(title)); }