Guard delayed updateOnline on the window

Task: 2026/08/15/survive-last-primary-close-after-an-extra-window
This commit is contained in:
John Preston
2026-08-15 12:27:37 +04:00
parent 8d657caf1a
commit 56ff88e136

View File

@@ -159,20 +159,6 @@ void Controller::showAccount(
_id.account = account;
Core::App().checkWindowId(this);
const auto updateOnlineOfPrevSesssion = crl::guard(account, [=] {
if (!prevSessionUniqueId) {
return;
}
for (auto &[index, account] : _id.account->domain().accounts()) {
if (const auto anotherSession = account->maybeSession()) {
if (anotherSession->uniqueId() == prevSessionUniqueId) {
anotherSession->updates().updateOnline(crl::now());
return;
}
}
}
});
if (!isPrimary()) {
_id.account->sessionChanges(
) | rpl::on_next([=](Main::Session *session) {
@@ -227,7 +213,19 @@ void Controller::showAccount(
_widget.updateGlobalMenu();
}
crl::on_main(updateOnlineOfPrevSesssion);
crl::on_main(this, [=] {
if (!prevSessionUniqueId) {
return;
}
for (auto &[index, account] : _id.account->domain().accounts()) {
if (const auto anotherSession = account->maybeSession()) {
if (anotherSession->uniqueId() == prevSessionUniqueId) {
anotherSession->updates().updateOnline(crl::now());
return;
}
}
}
});
}, _accountLifetime);
}