diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index c4eceb0429..86fecddf21 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -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; diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.h b/Telegram/SourceFiles/dialogs/dialogs_widget.h index 428b838fe6..b085c4f988 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.h @@ -166,6 +166,7 @@ private: void showSearchFrom(); void showMainMenu(); void clearSearchCache(); + void setSearchQuery(const QString &query); void updateControlsVisibility(bool fast = false); void updateLockUnlockVisibility(); void updateLoadMoreChatsVisibility(); diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index c6f98946b2..6af8c0c152 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -1344,6 +1344,12 @@ void TopBarWidget::searchClear() { } } +void TopBarWidget::searchSetText(const QString &query) { + if (_searchMode) { + _searchField->setText(query); + } +} + void TopBarWidget::toggleSelectedControls(bool shown) { _selectedShown.start( [this] { slideAnimationCallback(); }, diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h index 6d7316f6a0..17e6b82290 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h @@ -88,6 +88,7 @@ public: [[nodiscard]] rpl::producer searchQuery() const; [[nodiscard]] QString searchQueryCurrent() const; void searchClear(); + void searchSetText(const QString &query); [[nodiscard]] rpl::producer<> forwardSelectionRequest() const { return _forwardSelection.events();