mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-14 19:17:11 +00:00
Improved deleting peer from non-primary windows.
This commit is contained in:
parent
cc7a4c2772
commit
948ce77a8f
@ -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.
|
||||
//
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -1196,6 +1196,33 @@ void Application::closeWindow(not_null<Window::Controller*> window) {
|
||||
}
|
||||
}
|
||||
|
||||
void Application::closeChatFromWindows(not_null<PeerData*> 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::Controller*> window) {
|
||||
_lastActiveWindow = window;
|
||||
if (_mediaView && !_mediaView->isHidden()) {
|
||||
|
@ -171,6 +171,7 @@ public:
|
||||
void notifyFileDialogShown(bool shown);
|
||||
void checkSystemDarkMode();
|
||||
[[nodiscard]] bool isActiveForTrayMenu() const;
|
||||
void closeChatFromWindows(not_null<PeerData*> peer);
|
||||
|
||||
// Media view interface.
|
||||
bool hideMediaView();
|
||||
|
Loading…
Reference in New Issue
Block a user