mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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 "storage/localstorage.h"
|
||||||
#include "export/export_settings.h"
|
#include "export/export_settings.h"
|
||||||
#include "window/notifications_manager.h"
|
#include "window/notifications_manager.h"
|
||||||
|
#include "window/window_controller.h"
|
||||||
#include "data/data_peer_values.h" // Data::AmPremiumValue.
|
#include "data/data_peer_values.h" // Data::AmPremiumValue.
|
||||||
|
|
||||||
namespace Main {
|
namespace Main {
|
||||||
|
@ -340,27 +341,32 @@ void Domain::watchSession(not_null<Account*> account) {
|
||||||
return !session;
|
return !session;
|
||||||
}) | rpl::start_with_next([=] {
|
}) | rpl::start_with_next([=] {
|
||||||
scheduleUpdateUnreadBadge();
|
scheduleUpdateUnreadBadge();
|
||||||
if (account == _active.current()) {
|
closeAccountWindows(account);
|
||||||
activateAuthedAccount();
|
|
||||||
}
|
|
||||||
crl::on_main(&Core::App(), [=] {
|
crl::on_main(&Core::App(), [=] {
|
||||||
removeRedundantAccounts();
|
removeRedundantAccounts();
|
||||||
});
|
});
|
||||||
}, account->lifetime());
|
}, account->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Domain::activateAuthedAccount() {
|
void Domain::closeAccountWindows(not_null<Main::Account*> account) {
|
||||||
Expects(started());
|
auto another = (Main::Account*)nullptr;
|
||||||
|
|
||||||
if (_active.current()->sessionExists()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (auto i = _accounts.begin(); i != _accounts.end(); ++i) {
|
for (auto i = _accounts.begin(); i != _accounts.end(); ++i) {
|
||||||
if (i->account->sessionExists()) {
|
const auto other = i->account.get();
|
||||||
activate(i->account.get());
|
if (other == account) {
|
||||||
return;
|
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() {
|
bool Domain::removePasscodeIfEmpty() {
|
||||||
|
@ -384,9 +390,8 @@ void Domain::removeRedundantAccounts() {
|
||||||
Expects(started());
|
Expects(started());
|
||||||
|
|
||||||
const auto was = _accounts.size();
|
const auto was = _accounts.size();
|
||||||
activateAuthedAccount();
|
|
||||||
for (auto i = _accounts.begin(); i != _accounts.end();) {
|
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->account->sessionExists()) {
|
||||||
++i;
|
++i;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void activateAfterStarting();
|
void activateAfterStarting();
|
||||||
void activateAuthedAccount();
|
void closeAccountWindows(not_null<Main::Account*> account);
|
||||||
bool removePasscodeIfEmpty();
|
bool removePasscodeIfEmpty();
|
||||||
void removeRedundantAccounts();
|
void removeRedundantAccounts();
|
||||||
void watchSession(not_null<Account*> account);
|
void watchSession(not_null<Account*> account);
|
||||||
|
|
Loading…
Add table
Reference in a new issue