mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00: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:
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user