2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-02 07:35:12 +00:00

Single entry point to search in chat.

This commit is contained in:
John Preston
2023-01-18 15:17:32 +04:00
parent 2c75fe033c
commit f8e76f1b84
6 changed files with 23 additions and 39 deletions

View File

@@ -1481,9 +1481,7 @@ void Widget::showMainMenu() {
controller()->widget()->showMainMenu();
}
void Widget::searchMessages(
const QString &query,
Key inChat) {
void Widget::searchMessages(const QString &query, Key inChat) {
if (_childList) {
const auto forum = controller()->shownForum().current();
const auto topic = inChat.topic();
@@ -1494,18 +1492,27 @@ void Widget::searchMessages(
}
hideChildList();
}
if (_openedFolder) {
controller()->closeFolder();
}
const auto inChatChanged = [&] {
const auto inPeer = inChat.peer();
const auto inTopic = inChat.topic();
if (!inTopic && _openedForum && inPeer == _openedForum->channel()) {
if (!inTopic
&& _openedForum
&& inPeer == _openedForum->channel()
&& _subsectionTopBar
&& _subsectionTopBar->searchMode()) {
return false;
} else if ((inTopic || (inPeer && !inPeer->isForum()))
&& (inChat == _searchInChat)) {
return false;
} else if (const auto inPeer = inChat.peer()) {
if (inPeer->migrateTo() == _searchInChat.peer()
&& !_searchInChat.topic()) {
return false;
if (const auto to = inPeer->migrateTo()) {
if (to == _searchInChat.peer() && !_searchInChat.topic()) {
return false;
}
}
}
return true;
@@ -2130,18 +2137,7 @@ void Widget::closeChildList(anim::type animated) {
}
void Widget::searchInChat(Key chat) {
if (_openedForum && !chat.peer()->forum()) {
controller()->closeForum();
}
if (_openedFolder) {
if (_childList && _childList->setSearchInChat(chat)) {
return;
}
controller()->closeFolder();
}
cancelSearch();
setSearchInChat(chat);
applyFilterUpdate(true);
searchMessages(QString(), chat);
}
bool Widget::setSearchInChat(Key chat, PeerData *from) {