From 83f5025c9a4fc81f1709bfb28f615c53bd431cfb Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 9 Jul 2026 22:52:47 +0400 Subject: [PATCH] Redirect community open to its separate window --- .../window/window_session_controller.cpp | 19 ++++++++++++++++++- .../window/window_session_controller.h | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 4f6858cd8d..9654449223 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -2086,8 +2086,25 @@ void SessionController::closeFolder() { _openedFolder = nullptr; } +bool SessionController::openCommunityInDifferentWindow( + not_null info) { + const auto history = session().data().history(info->channel()); + const auto id = SeparateId(SeparateType::Community, history); + if (const auto separate = Core::App().separateWindowFor(id)) { + if (separate == _window) { + return false; + } + separate->sessionController()->showByInitialId(); + separate->activate(); + return true; + } + return false; +} + void SessionController::openCommunity(not_null info) { - if (_openedCommunity.current() != info) { + if (openCommunityInDifferentWindow(info)) { + return; + } else if (_openedCommunity.current() != info) { resetFakeUnreadWhileOpened(); } if (activeChatsFilterCurrent() != 0) { diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index d6b7e91e6a..83bda15591 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -798,6 +798,8 @@ private: void checkNonPremiumLimitToastUpload(FullMsgId id); bool openFolderInDifferentWindow(not_null folder); + bool openCommunityInDifferentWindow( + not_null info); bool showForumInDifferentWindow( not_null forum, const SectionShow ¶ms,