mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Remove non-authed account only without a window.
This commit is contained in:
parent
5278ed1f41
commit
f713585f17
2 changed files with 20 additions and 15 deletions
|
@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "storage/localstorage.h"
|
||||
#include "export/export_settings.h"
|
||||
#include "window/notifications_manager.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "data/data_peer_values.h" // Data::AmPremiumValue.
|
||||
|
||||
namespace Main {
|
||||
|
@ -340,27 +341,32 @@ void Domain::watchSession(not_null<Account*> account) {
|
|||
return !session;
|
||||
}) | rpl::start_with_next([=] {
|
||||
scheduleUpdateUnreadBadge();
|
||||
if (account == _active.current()) {
|
||||
activateAuthedAccount();
|
||||
}
|
||||
closeAccountWindows(account);
|
||||
crl::on_main(&Core::App(), [=] {
|
||||
removeRedundantAccounts();
|
||||
});
|
||||
}, account->lifetime());
|
||||
}
|
||||
|
||||
void Domain::activateAuthedAccount() {
|
||||
Expects(started());
|
||||
|
||||
if (_active.current()->sessionExists()) {
|
||||
return;
|
||||
}
|
||||
void Domain::closeAccountWindows(not_null<Main::Account*> account) {
|
||||
auto another = (Main::Account*)nullptr;
|
||||
for (auto i = _accounts.begin(); i != _accounts.end(); ++i) {
|
||||
if (i->account->sessionExists()) {
|
||||
activate(i->account.get());
|
||||
return;
|
||||
const auto other = i->account.get();
|
||||
if (other == account) {
|
||||
continue;
|
||||
} else if (Core::App().separateWindowForAccount(other)) {
|
||||
const auto that = Core::App().separateWindowForAccount(account);
|
||||
if (that) {
|
||||
that->close();
|
||||
}
|
||||
} else if (!another
|
||||
|| (other->sessionExists() && !another->sessionExists())) {
|
||||
another = other;
|
||||
}
|
||||
}
|
||||
if (another) {
|
||||
activate(another);
|
||||
}
|
||||
}
|
||||
|
||||
bool Domain::removePasscodeIfEmpty() {
|
||||
|
@ -384,9 +390,8 @@ void Domain::removeRedundantAccounts() {
|
|||
Expects(started());
|
||||
|
||||
const auto was = _accounts.size();
|
||||
activateAuthedAccount();
|
||||
for (auto i = _accounts.begin(); i != _accounts.end();) {
|
||||
if (i->account.get() == _active.current()
|
||||
if (Core::App().separateWindowForAccount(i->account.get())
|
||||
|| i->account->sessionExists()) {
|
||||
++i;
|
||||
continue;
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
|
||||
private:
|
||||
void activateAfterStarting();
|
||||
void activateAuthedAccount();
|
||||
void closeAccountWindows(not_null<Main::Account*> account);
|
||||
bool removePasscodeIfEmpty();
|
||||
void removeRedundantAccounts();
|
||||
void watchSession(not_null<Account*> account);
|
||||
|
|
Loading…
Add table
Reference in a new issue