diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index 593d6f4a0b..53e01dd106 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/application.h" #include "data/data_abstract_structure.h" +#include "data/data_channel.h" #include "data/data_forum.h" #include "data/data_message_reactions.h" #include "data/data_session.h" @@ -1377,8 +1378,9 @@ Window::Controller *Application::windowForShowingHistory( Window::Controller *Application::windowForShowingForum( not_null forum) const { + const auto tabs = forum->channel()->useSubsectionTabs(); const auto id = Window::SeparateId( - Window::SeparateType::Forum, + tabs ? Window::SeparateType::Chat : Window::SeparateType::Forum, forum->history()); if (const auto separate = separateWindowFor(id)) { return separate; @@ -1386,9 +1388,15 @@ Window::Controller *Application::windowForShowingForum( auto result = (Window::Controller*)nullptr; enumerateWindows([&](not_null window) { if (const auto controller = window->sessionController()) { - const auto current = controller->shownForum().current(); - if (forum == current) { - result = window; + if (tabs) { + if (controller->windowId() == id) { + result = window; + } + } else { + const auto current = controller->shownForum().current(); + if (forum == current) { + result = window; + } } } }); diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 06b1ac9294..6b6227b9a3 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -911,8 +911,10 @@ void Widget::chosenRow(const ChosenRow &row) { if (controller()->shownForum().current() == forum) { controller()->closeForum(); } else if (row.newWindow) { - controller()->showInNewWindow( - Window::SeparateId(Window::SeparateType::Forum, history)); + const auto type = forum->channel()->useSubsectionTabs() + ? Window::SeparateType::Chat + : Window::SeparateType::Forum; + controller()->showInNewWindow(Window::SeparateId(type, history)); } else { controller()->showForum( forum, diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index f34c3a1084..0038a41783 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -1176,9 +1176,11 @@ Window::SessionController *Manager::openNotificationMessage( } }); - const auto separateId = topic - ? Window::SeparateId(Window::SeparateType::Forum, history) - : Window::SeparateId(history->peer); + const auto separateId = !topic + ? Window::SeparateId(history->peer) + : history->peer->asChannel()->useSubsectionTabs() + ? Window::SeparateId(Window::SeparateType::Chat, topic) + : Window::SeparateId(Window::SeparateType::Forum, history); const auto separate = Core::App().separateWindowFor(separateId); const auto itemId = openExactlyMessage ? messageId : ShowAtUnreadMsgId; if (openSeparated && !separate && !topic) { diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 0f48fb48f7..477b1b6707 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -669,7 +669,7 @@ void Filler::addNewWindow() { if (const auto sublist = weak.get()) { controller->showInNewWindow(SeparateId( SeparateType::SavedSublist, - sublist->owner().history(sublist->sublistPeer()))); + sublist)); } }, &st::menuIconNewWindow); AddSeparatorAndShiftUp(_addAction); @@ -690,7 +690,9 @@ void Filler::addNewWindow() { _addAction(tr::lng_context_new_window(tr::now), [=] { Ui::PreventDelayedActivation(); if (const auto strong = weak.get()) { - const auto forum = !strong->asTopic() && peer->isForum(); + const auto forum = !strong->asTopic() + && peer->isForum() + && !peer->asChannel()->useSubsectionTabs(); controller->showInNewWindow(SeparateId( forum ? SeparateType::Forum : SeparateType::Chat, strong)); @@ -2472,7 +2474,7 @@ QPointer ShowForwardMessagesBox( return true; } const auto id = SeparateId( - (peer->isForum() + ((peer->isForum() && !peer->asChannel()->useSubsectionTabs()) ? SeparateType::Forum : SeparateType::Chat), thread); diff --git a/Telegram/SourceFiles/window/window_separate_id.cpp b/Telegram/SourceFiles/window/window_separate_id.cpp index c6b0f0da62..f6ed9155fd 100644 --- a/Telegram/SourceFiles/window/window_separate_id.cpp +++ b/Telegram/SourceFiles/window/window_separate_id.cpp @@ -31,14 +31,10 @@ SeparateId::SeparateId(SeparateType type, not_null session) , account(&session->account()) { } -SeparateId::SeparateId( - SeparateType type, - not_null thread, - ChannelData *parentChat) +SeparateId::SeparateId(SeparateType type, not_null thread) : type(type) , account(&thread->session().account()) -, thread(thread) -, parentChat((type == SeparateType::SavedSublist) ? parentChat : nullptr) { +, thread(thread) { } SeparateId::SeparateId(not_null thread) @@ -77,12 +73,9 @@ Data::Folder *SeparateId::folder() const { } Data::SavedSublist *SeparateId::sublist() const { - const auto monoforum = parentChat ? parentChat->monoforum() : nullptr; return (type != SeparateType::SavedSublist) ? nullptr - : monoforum - ? monoforum->sublist(thread->peer()).get() - : thread->owner().savedMessages().sublist(thread->peer()).get(); + : thread->asSublist(); } bool SeparateId::hasChatsList() const { diff --git a/Telegram/SourceFiles/window/window_separate_id.h b/Telegram/SourceFiles/window/window_separate_id.h index e36e8c2a98..dbc79397a5 100644 --- a/Telegram/SourceFiles/window/window_separate_id.h +++ b/Telegram/SourceFiles/window/window_separate_id.h @@ -46,10 +46,7 @@ struct SeparateId { SeparateId(std::nullptr_t); SeparateId(not_null account); SeparateId(SeparateType type, not_null session); - SeparateId( - SeparateType type, - not_null thread, - ChannelData *parentChat = nullptr); + SeparateId(SeparateType type, not_null thread); SeparateId(not_null thread); SeparateId(not_null peer); SeparateId( @@ -60,7 +57,6 @@ struct SeparateId { Storage::SharedMediaType sharedMediaType = {}; Main::Account *account = nullptr; Data::Thread *thread = nullptr; // For types except Main and Archive. - ChannelData *parentChat = nullptr; [[nodiscard]] bool valid() const { return account != nullptr; } diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 523777e882..1fe5d152cc 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -1877,8 +1877,7 @@ void SessionController::showForum( const SectionShow ¶ms) { if (showForumInDifferentWindow(forum, params)) { return; - } else if (HistoryView::SubsectionTabs::UsedFor( - forum->owner().history(forum->channel()))) { + } else if (forum->channel()->useSubsectionTabs()) { showPeerHistory(forum->channel(), params); return; }