2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Start chats search rewrite.

This commit is contained in:
John Preston
2024-05-17 14:56:56 +04:00
parent 787cf7853e
commit dd5643ac67
9 changed files with 474 additions and 491 deletions

View File

@@ -731,8 +731,18 @@ void MainWidget::hideSingleUseKeyboard(FullMsgId replyToId) {
}
void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat) {
auto tags = Data::SearchTagsFromQuery(query);
if (controller()->isPrimary()) {
_dialogs->searchMessages(query, inChat);
using Tab = Dialogs::ChatSearchTab;
auto state = Dialogs::SearchState{
.inChat = ((tags.empty() || inChat.sublist())
? inChat
: session().data().history(session().user())),
.tags = tags,
.query = tags.empty() ? query : QString(),
};
state.tab = state.defaultTabForMe();
_dialogs->searchMessages(std::move(state));
if (isOneColumn()) {
_controller->clearSectionStack();
} else {
@@ -742,7 +752,7 @@ void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat) {
if (const auto sublist = inChat.sublist()) {
controller()->showSection(
std::make_shared<HistoryView::SublistMemento>(sublist));
} else if (!Data::SearchTagsFromQuery(query).empty()) {
} else if (!tags.empty()) {
inChat = controller()->session().data().history(
controller()->session().user());
}