Removed redundant special tab mode from PeerListBox.

This commit is contained in:
23rd 2024-12-03 22:17:58 +03:00
parent a9e95a128f
commit 721877e10a
3 changed files with 3 additions and 36 deletions

View file

@ -217,19 +217,7 @@ void PeerListBox::keyPressEvent(QKeyEvent *e) {
void PeerListBox::searchQueryChanged(const QString &query) { void PeerListBox::searchQueryChanged(const QString &query) {
scrollToY(0); scrollToY(0);
const auto isEmpty = content()->searchQueryChanged(query); content()->searchQueryChanged(query);
if (_specialTabsMode.enabled) {
const auto was = _specialTabsMode.searchIsActive;
_specialTabsMode.searchIsActive = !isEmpty;
if (was != _specialTabsMode.searchIsActive) {
if (_specialTabsMode.searchIsActive) {
_specialTabsMode.topSkip = _addedTopScrollSkip;
setAddedTopScrollSkip(0);
} else {
setAddedTopScrollSkip(_specialTabsMode.topSkip);
}
}
}
} }
void PeerListBox::resizeEvent(QResizeEvent *e) { void PeerListBox::resizeEvent(QResizeEvent *e) {
@ -561,15 +549,6 @@ rpl::producer<int> PeerListBox::multiSelectHeightValue() const {
return _select ? _select->heightValue() : rpl::single(0); return _select ? _select->heightValue() : rpl::single(0);
} }
void PeerListBox::setSpecialTabMode(bool value) {
content()->setIgnoreHiddenRowsOnSearch(value);
if (value) {
_specialTabsMode.enabled = true;
} else {
_specialTabsMode = {};
}
}
PeerListRow::PeerListRow(not_null<PeerData*> peer) PeerListRow::PeerListRow(not_null<PeerData*> peer)
: PeerListRow(peer, peer->id.value) { : PeerListRow(peer, peer->id.value) {
} }
@ -2079,7 +2058,7 @@ void PeerListContent::checkScrollForPreload() {
} }
} }
PeerListContent::IsEmpty PeerListContent::searchQueryChanged(QString query) { void PeerListContent::searchQueryChanged(QString query) {
const auto searchWordsList = TextUtilities::PrepareSearchWords(query); const auto searchWordsList = TextUtilities::PrepareSearchWords(query);
const auto normalizedQuery = searchWordsList.join(' '); const auto normalizedQuery = searchWordsList.join(' ');
if (_ignoreHiddenRowsOnSearch && !normalizedQuery.isEmpty()) { if (_ignoreHiddenRowsOnSearch && !normalizedQuery.isEmpty()) {
@ -2136,7 +2115,6 @@ PeerListContent::IsEmpty PeerListContent::searchQueryChanged(QString query) {
} }
refreshRows(); refreshRows();
} }
return _normalizedSearchQuery.isEmpty();
} }
std::unique_ptr<PeerListState> PeerListContent::saveState() const { std::unique_ptr<PeerListState> PeerListContent::saveState() const {

View file

@ -652,8 +652,7 @@ public:
[[nodiscard]] bool hasPressed() const; [[nodiscard]] bool hasPressed() const;
void clearSelection(); void clearSelection();
using IsEmpty = bool; void searchQueryChanged(QString query);
IsEmpty searchQueryChanged(QString query);
bool submitted(); bool submitted();
PeerListRowId updateFromParentDrag(QPoint globalPosition); PeerListRowId updateFromParentDrag(QPoint globalPosition);
@ -1108,8 +1107,6 @@ public:
[[nodiscard]] std::vector<not_null<PeerData*>> collectSelectedRows(); [[nodiscard]] std::vector<not_null<PeerData*>> collectSelectedRows();
[[nodiscard]] rpl::producer<int> multiSelectHeightValue() const; [[nodiscard]] rpl::producer<int> multiSelectHeightValue() const;
void setSpecialTabMode(bool value);
void peerListSetTitle(rpl::producer<QString> title) override { void peerListSetTitle(rpl::producer<QString> title) override {
setTitle(std::move(title)); setTitle(std::move(title));
} }
@ -1175,11 +1172,4 @@ private:
bool _scrollBottomFixed = false; bool _scrollBottomFixed = false;
int _addedTopScrollSkip = 0; int _addedTopScrollSkip = 0;
struct SpecialTabsMode final {
bool enabled = false;
bool searchIsActive = false;
int topSkip = 0;
};
SpecialTabsMode _specialTabsMode;
}; };

View file

@ -2234,7 +2234,6 @@ QPointer<Ui::BoxContent> ShowForwardMessagesBox(
auto init = [=](not_null<ListBox*> box) { auto init = [=](not_null<ListBox*> box) {
controllerRaw->setSearchNoResultsText( controllerRaw->setSearchNoResultsText(
tr::lng_bot_chats_not_found(tr::now)); tr::lng_bot_chats_not_found(tr::now));
box->setSpecialTabMode(true);
const auto chatsFilters = Ui::AddChatFiltersTabsStrip( const auto chatsFilters = Ui::AddChatFiltersTabsStrip(
box, box,
session, session,