diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp index 67f7a84ea..3f3b6cab8 100644 --- a/Telegram/SourceFiles/core/click_handler_types.cpp +++ b/Telegram/SourceFiles/core/click_handler_types.cpp @@ -30,6 +30,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace { +// Possible context owners: media viewer, profile, history widget. + void SearchByHashtag(ClickContext context, const QString &tag) { const auto my = context.other.value(); const auto controller = my.sessionWindow.get(); @@ -172,9 +174,10 @@ QString MentionClickHandler::copyToClipboardContextItemText() const { void MentionClickHandler::onClick(ClickContext context) const { const auto button = context.button; if (button == Qt::LeftButton || button == Qt::MiddleButton) { - if (const auto m = App::main()) { // multi good + const auto my = context.other.value(); + if (const auto controller = my.sessionWindow.get()) { using Info = Window::SessionNavigation::PeerByLinkInfo; - m->controller()->showPeerByLink(Info{ + controller->showPeerByLink(Info{ .usernameOrId = _tag.mid(1), .resolveType = Window::ResolveType::Mention, }); @@ -189,8 +192,11 @@ auto MentionClickHandler::getTextEntity() const -> TextEntity { void MentionNameClickHandler::onClick(ClickContext context) const { const auto button = context.button; if (button == Qt::LeftButton || button == Qt::MiddleButton) { - if (auto user = _session->data().userLoaded(_userId)) { - Ui::showPeerProfile(user); + const auto my = context.other.value(); + if (const auto controller = my.sessionWindow.get()) { + if (auto user = _session->data().userLoaded(_userId)) { + controller->showPeerInfo(user); + } } } } diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index 3a0c749a9..236d622f5 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -251,29 +251,6 @@ void activateBotCommand( namespace Ui { -void showPeerProfile(not_null peer) { - if (const auto window = App::wnd()) { // multi good - if (const auto controller = window->sessionController()) { - if (&controller->session() == &peer->session()) { - controller->showPeerInfo(peer); - return; - } - } - if (&Core::App().domain().active() != &peer->session().account()) { - Core::App().domain().activate(&peer->session().account()); - } - if (const auto controller = window->sessionController()) { - if (&controller->session() == &peer->session()) { - controller->showPeerInfo(peer); - } - } - } -} - -void showPeerProfile(not_null history) { - showPeerProfile(history->peer); -} - void showChatsList(not_null session) { if (const auto m = CheckMainWidget(session)) { m->ui_showPeerHistory( diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index af145d7cf..3bd1a0566 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -47,9 +47,6 @@ namespace Ui { // Legacy global methods. -void showPeerProfile(not_null peer); -void showPeerProfile(not_null history); - void showPeerHistory(not_null peer, MsgId msgId); void showPeerHistory(not_null history, MsgId msgId); void showChatsList(not_null session); diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index f492a7669..51fbce41c 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -79,7 +79,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/file_download.h" #include "storage/storage_account.h" #include "calls/calls_instance.h" -#include "facades.h" #include "styles/style_media_view.h" #include "styles/style_chat.h" #include "styles/style_menu_icons.h" @@ -4482,7 +4481,9 @@ void OverlayWidget::handleMouseRelease( if (_over == OverName && _down == OverName) { if (_from) { close(); - Ui::showPeerProfile(_from); + if (const auto window = findWindow(true)) { + window->showPeerInfo(_from); + } } } else if (_over == OverDate && _down == OverDate) { toMessage();