From 05f1caf9445cc347f421ab15379806f6ed49cf8c Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 26 Jul 2021 21:22:33 +0300 Subject: [PATCH] Removed App::searchByHashtag from facades. --- .../SourceFiles/core/click_handler_types.cpp | 36 +++++++++++++++++-- Telegram/SourceFiles/facades.cpp | 18 ---------- Telegram/SourceFiles/facades.h | 1 - 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp index 32d1c465e..2314e3c42 100644 --- a/Telegram/SourceFiles/core/click_handler_types.cpp +++ b/Telegram/SourceFiles/core/click_handler_types.cpp @@ -11,10 +11,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/application.h" #include "core/local_url_handlers.h" #include "mainwidget.h" +#include "mainwindow.h" #include "main/main_session.h" #include "boxes/confirm_box.h" #include "base/qthelp_regex.h" #include "storage/storage_account.h" +#include "history/history.h" #include "history/view/history_view_element.h" #include "history/history_item.h" #include "data/data_user.h" @@ -25,6 +27,36 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include +namespace { + +void SearchByHashtag(ClickContext context, const QString &tag) { + const auto my = context.other.value(); + const auto controller = my.sessionWindow.get(); + if (!controller) { + return; + } + if (controller->openedFolder().current()) { + controller->closeFolder(); + } + + controller->widget()->ui_hideSettingsAndLayer(anim::type::normal); + Core::App().hideMediaView(); + + auto &data = controller->session().data(); + const auto inPeer = my.peer + ? my.peer + : my.itemId + ? data.message(my.itemId)->history()->peer + : nullptr; + controller->content()->searchMessages( + tag + ' ', + (inPeer && !inPeer->isUser()) + ? data.history(inPeer).get() + : Dialogs::Key()); +} + +} // namespace + bool UrlRequiresConfirmation(const QUrl &url) { using namespace qthelp; @@ -159,7 +191,7 @@ QString HashtagClickHandler::copyToClipboardContextItemText() const { void HashtagClickHandler::onClick(ClickContext context) const { const auto button = context.button; if (button == Qt::LeftButton || button == Qt::MiddleButton) { - App::searchByHashtag(_tag, Ui::getPeerForMouseAction()); + SearchByHashtag(context, _tag); } } @@ -174,7 +206,7 @@ QString CashtagClickHandler::copyToClipboardContextItemText() const { void CashtagClickHandler::onClick(ClickContext context) const { const auto button = context.button; if (button == Qt::LeftButton || button == Qt::MiddleButton) { - App::searchByHashtag(_tag, Ui::getPeerForMouseAction()); + SearchByHashtag(context, _tag); } } diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index 48d58322b..4bfb64cfc 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -215,24 +215,6 @@ void activateBotCommand( } } -void searchByHashtag(const QString &tag, PeerData *inPeer) { - const auto m = inPeer - ? CheckMainWidget(&inPeer->session()) - : App::main(); // multi good - if (m) { - if (m->controller()->openedFolder().current()) { - m->controller()->closeFolder(); - } - Ui::hideSettingsAndLayer(); - Core::App().hideMediaView(); - m->searchMessages( - tag + ' ', - (inPeer && !inPeer->isUser()) - ? inPeer->owner().history(inPeer).get() - : Dialogs::Key()); - } -} - } // namespace App namespace Ui { diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index b3f53c72a..72655e3c8 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -47,7 +47,6 @@ void activateBotCommand( not_null msg, int row, int column); -void searchByHashtag(const QString &tag, PeerData *inPeer); } // namespace App