From 31c745cb07beb734a1a5af34af1de9739a944b95 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 26 Jun 2020 14:36:52 +0400 Subject: [PATCH] Destroy non-authed account on deactivate. --- Telegram/SourceFiles/main/main_domain.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/main/main_domain.cpp b/Telegram/SourceFiles/main/main_domain.cpp index d4e2945fe..845787c24 100644 --- a/Telegram/SourceFiles/main/main_domain.cpp +++ b/Telegram/SourceFiles/main/main_domain.cpp @@ -341,10 +341,12 @@ void Domain::activate(not_null 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 account) { ) | rpl::start_to_stream(_activeSessions, _activeLifetime); if (changed) { - scheduleWriteAccounts(); + if (wasAuthed) { + scheduleWriteAccounts(); + } else { + crl::on_main(&Core::App(), [=] { + removeRedundantAccounts(); + }); + } } }