2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-05 00:55:12 +00:00

Fix search by a hashtag from a topic.

This commit is contained in:
John Preston
2022-12-22 11:17:50 +04:00
parent 98af2d3006
commit 7cf3babcbd
4 changed files with 28 additions and 2 deletions

View File

@@ -1466,6 +1466,16 @@ void Widget::showMainMenu() {
void Widget::searchMessages(
const QString &query,
Key inChat) {
if (_childList) {
const auto forum = controller()->shownForum().current();
const auto topic = inChat.topic();
if ((forum && forum->channel() == inChat.peer())
|| (topic && topic->forum() == forum)) {
_childList->searchMessages(query, inChat);
return;
}
hideChildList();
}
const auto inChatChanged = [&] {
const auto inPeer = inChat.peer();
const auto inTopic = inChat.topic();
@@ -1482,12 +1492,12 @@ void Widget::searchMessages(
}
return true;
}();
if ((_filter->getLastText() != query) || inChatChanged) {
if ((currentSearchQuery() != query) || inChatChanged) {
if (inChat) {
cancelSearch();
setSearchInChat(inChat);
}
_filter->setText(query);
setSearchQuery(query);
applyFilterUpdate(true);
_searchTimer.cancel();
searchMessages();
@@ -2570,6 +2580,14 @@ void Widget::clearSearchField() {
}
}
void Widget::setSearchQuery(const QString &query) {
if (_subsectionTopBar) {
_subsectionTopBar->searchSetText(query);
} else {
_filter->setText(query);
}
}
bool Widget::cancelSearch() {
auto clearingQuery = !currentSearchQuery().isEmpty();
auto clearingInChat = false;