diff --git a/Telegram/SourceFiles/settings/settings_privacy_security.cpp b/Telegram/SourceFiles/settings/settings_privacy_security.cpp index 79aa816c8e..7df986a73e 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_security.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_security.cpp @@ -328,20 +328,23 @@ void SetupCloudPassword(not_null container) { }); auto confirmation = rpl::single( lang(lng_profile_loading) - ) | rpl::then(base::duplicate( + ) | rpl::then(rpl::duplicate( pattern ) | rpl::filter([](const QString &pattern) { return !pattern.isEmpty(); }) | rpl::map([](const QString &pattern) { return lng_cloud_password_waiting_code(lt_email, pattern); })); - auto unconfirmed = rpl::single( - true - ) | rpl::then(base::duplicate( + auto unconfirmed = rpl::duplicate( pattern ) | rpl::map([](const QString &pattern) { return !pattern.isEmpty(); - })); + }); + auto noconfirmed = rpl::single( + true + ) | rpl::then(rpl::duplicate( + unconfirmed + )); const auto label = container->add( object_ptr>( container, @@ -356,7 +359,7 @@ void SetupCloudPassword(not_null container) { (st::settingsButton.height - st::settingsCloudPasswordLabel.style.font->height + st::settingsButton.padding.bottom())))); - label->toggleOn(base::duplicate(unconfirmed))->setDuration(0); + label->toggleOn(base::duplicate(noconfirmed))->setDuration(0); std::move( confirmation @@ -379,10 +382,10 @@ void SetupCloudPassword(not_null container) { std::move(text), st::settingsButton))); change->toggleOn(rpl::duplicate( - unconfirmed - ) | rpl::map([](bool unconfirmed) { - return !unconfirmed; - }))->setDuration(0); + noconfirmed + ) | rpl::map( + !_1 + ))->setDuration(0); change->entity()->addClickHandler([] { if (CheckEditCloudPassword()) { EditCloudPassword(); @@ -396,11 +399,16 @@ void SetupCloudPassword(not_null container) { container, Lang::Viewer(lng_cloud_password_confirm), st::settingsButton))); - confirm->toggleOn(rpl::duplicate( + confirm->toggleOn(rpl::single( + false + ) | rpl::then(rpl::duplicate( unconfirmed - ))->setDuration(0); + )))->setDuration(0); confirm->entity()->addClickHandler([] { const auto state = Auth().api().passwordStateCurrent(); + if (!state) { + return; + } auto validation = ConfirmRecoveryEmail(state->unconfirmedPattern); std::move( @@ -432,7 +440,7 @@ void SetupCloudPassword(not_null container) { st::settingsButton))); disable->toggleOn(rpl::combine( rpl::duplicate(has), - rpl::duplicate(unconfirmed), + rpl::duplicate(noconfirmed), _1 && !_2)); disable->entity()->addClickHandler(remove); @@ -445,7 +453,7 @@ void SetupCloudPassword(not_null container) { st::settingsAttentionButton))); abort->toggleOn(rpl::combine( rpl::duplicate(has), - rpl::duplicate(unconfirmed), + rpl::duplicate(noconfirmed), _1 && _2)); abort->entity()->addClickHandler(remove);