mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improved deleting peer from non-primary windows.
This commit is contained in:
parent
cc7a4c2772
commit
948ce77a8f
4 changed files with 32 additions and 10 deletions
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "api/api_chat_participants.h"
|
#include "api/api_chat_participants.h"
|
||||||
#include "api/api_messages_search.h"
|
#include "api/api_messages_search.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
|
#include "core/application.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_histories.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/buttons.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
#include "ui/widgets/labels.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_layers.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
|
||||||
|
@ -493,11 +492,7 @@ void DeleteMessagesBox::deleteAndClear() {
|
||||||
if (justClear) {
|
if (justClear) {
|
||||||
session->api().clearHistory(peer, revoke);
|
session->api().clearHistory(peer, revoke);
|
||||||
} else {
|
} else {
|
||||||
for (const auto &controller : session->windows()) {
|
Core::App().closeChatFromWindows(peer);
|
||||||
if (controller->activeChatCurrent().peer() == peer) {
|
|
||||||
Ui::showChatsList(session);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Don't delete old history by default,
|
// Don't delete old history by default,
|
||||||
// because Android app doesn't.
|
// because Android app doesn't.
|
||||||
//
|
//
|
||||||
|
|
|
@ -53,7 +53,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "info/profile/info_profile_icon.h"
|
#include "info/profile/info_profile_icon.h"
|
||||||
#include "api/api_invite_links.h"
|
#include "api/api_invite_links.h"
|
||||||
#include "facades.h" // Ui::showChatsList
|
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
#include "styles/style_info.h"
|
#include "styles/style_info.h"
|
||||||
|
@ -1702,8 +1701,8 @@ void Controller::deleteChannel() {
|
||||||
|
|
||||||
const auto session = &_peer->session();
|
const auto session = &_peer->session();
|
||||||
|
|
||||||
Ui::hideLayer();
|
_navigation->parentController()->hideLayer();
|
||||||
Ui::showChatsList(session);
|
Core::App().closeChatFromWindows(_peer);
|
||||||
if (chat) {
|
if (chat) {
|
||||||
session->api().deleteConversation(chat, false);
|
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) {
|
void Application::windowActivated(not_null<Window::Controller*> window) {
|
||||||
_lastActiveWindow = window;
|
_lastActiveWindow = window;
|
||||||
if (_mediaView && !_mediaView->isHidden()) {
|
if (_mediaView && !_mediaView->isHidden()) {
|
||||||
|
|
|
@ -171,6 +171,7 @@ public:
|
||||||
void notifyFileDialogShown(bool shown);
|
void notifyFileDialogShown(bool shown);
|
||||||
void checkSystemDarkMode();
|
void checkSystemDarkMode();
|
||||||
[[nodiscard]] bool isActiveForTrayMenu() const;
|
[[nodiscard]] bool isActiveForTrayMenu() const;
|
||||||
|
void closeChatFromWindows(not_null<PeerData*> peer);
|
||||||
|
|
||||||
// Media view interface.
|
// Media view interface.
|
||||||
bool hideMediaView();
|
bool hideMediaView();
|
||||||
|
|
Loading…
Add table
Reference in a new issue