From 66d54ccd54c713a70e20543f0e3bb45d62fc2e89 Mon Sep 17 00:00:00 2001 From: AlexeyZavar Date: Sun, 9 Mar 2025 02:59:45 +0300 Subject: [PATCH] feat: open channel in discussion group --- .../ayu/ui/context_menu/context_menu.cpp | 21 +++++++++++++++++++ .../ayu/ui/context_menu/context_menu.h | 4 ++++ .../SourceFiles/window/window_peer_menu.cpp | 2 ++ 3 files changed, 27 insertions(+) diff --git a/Telegram/SourceFiles/ayu/ui/context_menu/context_menu.cpp b/Telegram/SourceFiles/ayu/ui/context_menu/context_menu.cpp index cc35ed0c2..04f8f7016 100644 --- a/Telegram/SourceFiles/ayu/ui/context_menu/context_menu.cpp +++ b/Telegram/SourceFiles/ayu/ui/context_menu/context_menu.cpp @@ -149,6 +149,27 @@ void AddJumpToBeginningAction(PeerData *peerData, &st::ayuMenuIconToBeginning); } +void AddOpenChannelAction(PeerData *peerData, + not_null sessionController, + const Window::PeerMenuCallback &addCallback) { + if (!peerData || !peerData->isMegagroup()) { + return; + } + + const auto chat = peerData->asMegagroup()->linkedChat(); + if (!chat) { + return; + } + + addCallback( + tr::lng_context_open_channel(tr::now), + [=] + { + sessionController->showPeerHistory(chat, Window::SectionShow::Way::Forward); + }, + &st::menuIconChannel); +} + void AddHistoryAction(not_null menu, HistoryItem *item) { if (AyuMessages::hasRevisions(item)) { menu->addAction( diff --git a/Telegram/SourceFiles/ayu/ui/context_menu/context_menu.h b/Telegram/SourceFiles/ayu/ui/context_menu/context_menu.h index bde7c6ae5..1a422aad0 100644 --- a/Telegram/SourceFiles/ayu/ui/context_menu/context_menu.h +++ b/Telegram/SourceFiles/ayu/ui/context_menu/context_menu.h @@ -25,6 +25,10 @@ void AddJumpToBeginningAction(PeerData *peerData, not_null sessionController, const Window::PeerMenuCallback &addCallback); +void AddOpenChannelAction(PeerData *peerData, + not_null sessionController, + const Window::PeerMenuCallback &addCallback); + void AddHistoryAction(not_null menu, HistoryItem *item); void AddHideMessageAction(not_null menu, HistoryItem *item); void AddUserMessagesAction(not_null menu, HistoryItem *item); diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 08bc6ec40..54faff992 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -1444,6 +1444,7 @@ void Filler::fillHistoryActions() { addToggleMuteSubmenu(true); addInfo(); AyuUi::AddJumpToBeginningAction(_peer, _thread, _controller, _addAction); + AyuUi::AddOpenChannelAction(_peer, _controller, _addAction); addViewAsTopics(); addManageChat(); addStoryArchive(); @@ -1476,6 +1477,7 @@ void Filler::fillProfileActions() { addTopicLink(); addManageTopic(); addToggleTopicClosed(); + AyuUi::AddOpenChannelAction(_peer, _controller, _addAction); addViewDiscussion(); addExportChat(); addToggleFolder();