mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Fixed online status stuck when switching between accounts one more time.
The first attempt to fix this bug is here:8171ed6c12
. It caused crash so it was reverted here:2ef47222f4
.
This commit is contained in:
parent
65e2bbee3e
commit
972bbbce6a
2 changed files with 20 additions and 0 deletions
|
@ -157,6 +157,7 @@ Session::Session(
|
|||
|
||||
// Can be called only right before ~Session.
|
||||
void Session::finishLogout() {
|
||||
updates().updateOnline();
|
||||
unlockTerms();
|
||||
data().clear();
|
||||
data().clearLocalStorage();
|
||||
|
|
|
@ -51,9 +51,26 @@ Controller::~Controller() {
|
|||
}
|
||||
|
||||
void Controller::showAccount(not_null<Main::Account*> account) {
|
||||
const auto prevSessionUniqueId = (_account && _account->sessionExists())
|
||||
? _account->session().uniqueId()
|
||||
: 0;
|
||||
_accountLifetime.destroy();
|
||||
_account = account;
|
||||
|
||||
const auto updateOnlineOfPrevSesssion = crl::guard(_account, [=] {
|
||||
if (!prevSessionUniqueId) {
|
||||
return;
|
||||
}
|
||||
for (auto &[index, account] : _account->domain().accounts()) {
|
||||
if (const auto anotherSession = account->maybeSession()) {
|
||||
if (anotherSession->uniqueId() == prevSessionUniqueId) {
|
||||
anotherSession->updates().updateOnline();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
_account->sessionValue(
|
||||
) | rpl::start_with_next([=](Main::Session *session) {
|
||||
const auto was = base::take(_sessionController);
|
||||
|
@ -84,6 +101,8 @@ void Controller::showAccount(not_null<Main::Account*> account) {
|
|||
setupIntro();
|
||||
_widget.updateGlobalMenu();
|
||||
}
|
||||
|
||||
crl::on_main(updateOnlineOfPrevSesssion);
|
||||
}, _accountLifetime);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue