Fix crash in wrong confirm email button.

This commit is contained in:
John Preston 2018-12-25 14:52:53 +04:00
parent d1be4c6d96
commit 9c579e0d5b

View File

@ -328,20 +328,23 @@ void SetupCloudPassword(not_null<Ui::VerticalLayout*> 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<Ui::SlideWrap<Ui::FlatLabel>>(
container,
@ -356,7 +359,7 @@ void SetupCloudPassword(not_null<Ui::VerticalLayout*> 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<Ui::VerticalLayout*> 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<Ui::VerticalLayout*> 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<Ui::VerticalLayout*> 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<Ui::VerticalLayout*> container) {
st::settingsAttentionButton)));
abort->toggleOn(rpl::combine(
rpl::duplicate(has),
rpl::duplicate(unconfirmed),
rpl::duplicate(noconfirmed),
_1 && _2));
abort->entity()->addClickHandler(remove);