diff --git a/Telegram/SourceFiles/boxes/delete_messages_box.cpp b/Telegram/SourceFiles/boxes/delete_messages_box.cpp index 21f024ac57..4b5da52b96 100644 --- a/Telegram/SourceFiles/boxes/delete_messages_box.cpp +++ b/Telegram/SourceFiles/boxes/delete_messages_box.cpp @@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "api/api_chat_participants.h" #include "api/api_messages_search.h" #include "base/unixtime.h" +#include "core/application.h" #include "data/data_channel.h" #include "data/data_chat.h" #include "data/data_histories.h" @@ -26,8 +27,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/buttons.h" #include "ui/widgets/checkbox.h" #include "ui/widgets/labels.h" -#include "window/window_session_controller.h" -#include "facades.h" // Ui::showChatsList #include "styles/style_layers.h" #include "styles/style_boxes.h" @@ -493,11 +492,7 @@ void DeleteMessagesBox::deleteAndClear() { if (justClear) { session->api().clearHistory(peer, revoke); } else { - for (const auto &controller : session->windows()) { - if (controller->activeChatCurrent().peer() == peer) { - Ui::showChatsList(session); - } - } + Core::App().closeChatFromWindows(peer); // Don't delete old history by default, // because Android app doesn't. // diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index 1e22b8a7c4..df5ee03160 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -53,7 +53,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/window_session_controller.h" #include "info/profile/info_profile_icon.h" #include "api/api_invite_links.h" -#include "facades.h" // Ui::showChatsList #include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_info.h" @@ -1702,8 +1701,8 @@ void Controller::deleteChannel() { const auto session = &_peer->session(); - Ui::hideLayer(); - Ui::showChatsList(session); + _navigation->parentController()->hideLayer(); + Core::App().closeChatFromWindows(_peer); if (chat) { session->api().deleteConversation(chat, false); } diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index 439e0d0cef..ad4b41e597 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -1196,6 +1196,33 @@ void Application::closeWindow(not_null window) { } } +void Application::closeChatFromWindows(not_null peer) { + for (const auto &[history, window] : _secondaryWindows) { + if (!window) { + continue; + } + if (history->peer == peer) { + closeWindow(window.get()); + } else if (const auto session = window->sessionController()) { + if (session->activeChatCurrent().peer() == peer) { + session->showPeerHistory( + window->singlePeer()->id, + Window::SectionShow::Way::ClearStack); + } + } + } + if (_primaryWindow && _primaryWindow->sessionController()) { + const auto primary = _primaryWindow->sessionController(); + if ((primary->activeChatCurrent().peer() == peer) + && (&primary->session() == &peer->session())) { + // showChatsList + primary->showPeerHistory( + PeerId(0), + Window::SectionShow::Way::ClearStack); + } + } +} + void Application::windowActivated(not_null window) { _lastActiveWindow = window; if (_mediaView && !_mediaView->isHidden()) { diff --git a/Telegram/SourceFiles/core/application.h b/Telegram/SourceFiles/core/application.h index 5853f72935..b7753f33c7 100644 --- a/Telegram/SourceFiles/core/application.h +++ b/Telegram/SourceFiles/core/application.h @@ -171,6 +171,7 @@ public: void notifyFileDialogShown(bool shown); void checkSystemDarkMode(); [[nodiscard]] bool isActiveForTrayMenu() const; + void closeChatFromWindows(not_null peer); // Media view interface. bool hideMediaView();