2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-01 15:05:56 +00:00

Show empty / placeholder in chats search.

This commit is contained in:
John Preston
2024-05-21 13:16:08 +04:00
parent 279db771cf
commit e00c6ecfb8
10 changed files with 264 additions and 66 deletions

View File

@@ -345,6 +345,10 @@ Widget::Widget(
}
applySearchState(std::move(copy));
}, lifetime());
_inner->cancelSearchRequests(
) | rpl::start_with_next([=] {
applySearchState({});
}, lifetime());
_inner->chosenRow(
) | rpl::start_with_next([=](const ChosenRow &row) {
chosenRow(row);
@@ -1988,6 +1992,9 @@ bool Widget::search(bool inCache) {
auto result = false;
const auto query = _searchState.query.trimmed();
const auto trimmed = (query.isEmpty() || query[0] != '#')
? query
: query.mid(1).trimmed();
const auto inPeer = searchInPeer();
const auto fromPeer = searchFromPeer();
const auto &inTags = searchInTags();
@@ -1995,9 +2002,7 @@ bool Widget::search(bool inCache) {
const auto fromStartType = inPeer
? SearchRequestType::PeerFromStart
: SearchRequestType::FromStart;
const auto skipRequest = (query.isEmpty() && !fromPeer && inTags.empty())
|| (tab == ChatSearchTab::PublicPosts && query.size() < 2);
if (skipRequest) {
if (trimmed.isEmpty() && !fromPeer && inTags.empty()) {
cancelSearchRequest();
searchApplyEmpty(fromStartType, 0);
_api.request(base::take(_peerSearchRequest)).cancel();
@@ -2021,10 +2026,7 @@ bool Widget::search(bool inCache) {
_searchNextRate = 0;
_searchFull = _searchFullMigrated = false;
cancelSearchRequest();
searchReceived(
fromStartType,
i->second,
0);
searchReceived(fromStartType, i->second, 0);
result = true;
}
} else if (_searchQuery != query