diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 489a076e5f..85e395cdb8 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -3069,6 +3069,11 @@ void InnerWidget::clearSelection() { } void InnerWidget::fillSupportSearchMenu(not_null menu) { + const auto globalSearch = (_searchState.tab == ChatSearchTab::MyMessages) + || (_searchState.tab == ChatSearchTab::PublicPosts); + if (!globalSearch && _searchState.inChat) { + return; + } const auto all = session().settings().supportAllSearchResults(); const auto text = all ? "Only one from chat" : "Show all messages"; menu->addAction(text, [=] { @@ -3079,9 +3084,11 @@ void InnerWidget::fillSupportSearchMenu(not_null menu) { void InnerWidget::fillArchiveSearchMenu(not_null menu) { const auto folder = session().data().folderLoaded(Data::Folder::kId); + const auto globalSearch = (_searchState.tab == ChatSearchTab::MyMessages) + || (_searchState.tab == ChatSearchTab::PublicPosts); if (!folder || !folder->chatsList()->fullSize().current() - || _searchState.inChat) { + || (!globalSearch && _searchState.inChat)) { return; } const auto skip = session().settings().skipArchiveInSearch(); @@ -3796,7 +3803,7 @@ void InnerWidget::itemRemoved(not_null item) { } bool InnerWidget::uniqueSearchResults() const { - return _controller->uniqueChatsInSearchResults(); + return _controller->uniqueChatsInSearchResults(_searchState); } bool InnerWidget::hasHistoryInResults(not_null history) const { @@ -3854,7 +3861,8 @@ void InnerWidget::searchReceived( ? _searchState.inChat : Key(_openedForum->history()); if (inject - && (!_searchState.inChat + && (globalSearch + || !_searchState.inChat || inject->history() == _searchState.inChat.history())) { Assert(_searchResults.empty()); Assert(!toPreview); diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index e3dc7d97cb..74c6f2d297 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -967,9 +967,9 @@ void Widget::chosenRow(const ChosenRow &row) { return; } else if (history) { const auto peer = history->peer; - const auto showAtMsgId = controller()->uniqueChatsInSearchResults() - ? ShowAtUnreadMsgId - : row.message.fullId.msg; + const auto showAtMsgId = controller()->uniqueChatsInSearchResults( + _searchState + ) ? ShowAtUnreadMsgId : row.message.fullId.msg; auto params = Window::SectionShow( Window::SectionShow::Way::ClearStack); params.highlightPart.text = _searchState.query; diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 9ef02540bb..19c93e4016 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -53,6 +53,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_peer_values.h" #include "data/data_premium_limits.h" #include "data/data_web_page.h" +#include "dialogs/ui/chat_search_in.h" #include "passport/passport_form_controller.h" #include "chat_helpers/tabbed_selector.h" #include "chat_helpers/emoji_interactions.h" @@ -1803,10 +1804,13 @@ void SessionController::activateFirstChatsFilter() { setActiveChatsFilter(session().data().chatsFilters().defaultId()); } -bool SessionController::uniqueChatsInSearchResults() const { +bool SessionController::uniqueChatsInSearchResults( + const Dialogs::SearchState &state) const { + const auto global = (state.tab == Dialogs::ChatSearchTab::MyMessages) + || (state.tab == Dialogs::ChatSearchTab::PublicPosts); return session().supportMode() && !session().settings().supportAllSearchResults() - && !_searchInChat.current(); + && (global || !state.inChat); } bool SessionController::openFolderInDifferentWindow( diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index 9af6714b60..ab9290d70a 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -30,6 +30,10 @@ class SavedMessages; enum class StorySourcesList : uchar; } // namespace Data +namespace Dialogs { +struct SearchState; +} // namespace Dialogs + namespace ChatHelpers { class TabbedSelector; class EmojiInteractions; @@ -404,7 +408,7 @@ public: void setSearchInChat(Dialogs::Key value) { _searchInChat = value; } - bool uniqueChatsInSearchResults() const; + bool uniqueChatsInSearchResults(const Dialogs::SearchState &state) const; void openFolder(not_null folder); void closeFolder();