Fixed leak of setup email unlock subscription in session.

This commit is contained in:
23rd
2026-09-13 07:23:33 +03:00
parent b86d8d1362
commit 460f41d1d3

View File

@@ -144,16 +144,22 @@ Session::Session(
// base::call_delayed(5000, [=] {
Core::App().lockBySetupEmail();
});
const auto weak = base::make_weak(this);
const auto unlockLifetime = std::make_shared<rpl::lifetime>();
_promoSuggestions->setupEmailStateValue(
) | rpl::filter([](Data::SetupEmailState s) {
return s == Data::SetupEmailState::None;
}) | rpl::take(1) | rpl::on_next(crl::guard(this, [=] {
}) | rpl::take(1) | rpl::on_next_done([=] {
unlockLifetime->destroy();
if (!weak) {
return;
}
Core::App().unlockSetupEmail();
_settings->setSetupEmailState(State::None);
saveSettingsDelayed(200);
}, [=] {
unlockLifetime->destroy();
}), *unlockLifetime);
}, *unlockLifetime);
} else {
_settings->setSetupEmailState(
_promoSuggestions->setupEmailState());