Destroy non-authed account on deactivate.

This commit is contained in:
John Preston 2020-06-26 14:36:52 +04:00
parent c8efb77520
commit 31c745cb07

View file

@ -341,10 +341,12 @@ void Domain::activate(not_null<Main::Account*> account) {
});
Assert(i != end(_accounts));
const auto changed = (_accountToActivate != i->index);
auto wasAuthed = false;
_activeLifetime.destroy();
if (_active.current()) {
_lastActiveIndex = _accountToActivate;
wasAuthed = _active.current()->sessionExists();
}
_accountToActivate = i->index;
_active = account.get();
@ -352,7 +354,13 @@ void Domain::activate(not_null<Main::Account*> account) {
) | rpl::start_to_stream(_activeSessions, _activeLifetime);
if (changed) {
scheduleWriteAccounts();
if (wasAuthed) {
scheduleWriteAccounts();
} else {
crl::on_main(&Core::App(), [=] {
removeRedundantAccounts();
});
}
}
}