mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Swap confirm and password boxes on export.
This commit is contained in:
parent
c3195cfcbe
commit
3fb0fa6892
1 changed files with 25 additions and 21 deletions
|
@ -78,8 +78,7 @@ private:
|
||||||
void ConfirmExportBox(
|
void ConfirmExportBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
std::shared_ptr<Data::UniqueGift> gift,
|
std::shared_ptr<Data::UniqueGift> gift,
|
||||||
const QString &url,
|
Fn<void(Fn<void()> close)> confirmed) {
|
||||||
Fn<void()> wentToUrl) {
|
|
||||||
box->setTitle(tr::lng_gift_transfer_confirm_title());
|
box->setTitle(tr::lng_gift_transfer_confirm_title());
|
||||||
box->addRow(object_ptr<Ui::FlatLabel>(
|
box->addRow(object_ptr<Ui::FlatLabel>(
|
||||||
box,
|
box,
|
||||||
|
@ -89,9 +88,11 @@ void ConfirmExportBox(
|
||||||
Ui::Text::WithEntities),
|
Ui::Text::WithEntities),
|
||||||
st::boxLabel));
|
st::boxLabel));
|
||||||
box->addButton(tr::lng_gift_transfer_confirm_button(), [=] {
|
box->addButton(tr::lng_gift_transfer_confirm_button(), [=] {
|
||||||
UrlClickHandler::Open(url);
|
confirmed([weak = Ui::MakeWeak(box)] {
|
||||||
wentToUrl();
|
if (const auto strong = weak.data()) {
|
||||||
box->closeBox();
|
strong->closeBox();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
box->addButton(tr::lng_cancel(), [=] {
|
box->addButton(tr::lng_cancel(), [=] {
|
||||||
box->closeBox();
|
box->closeBox();
|
||||||
|
@ -103,7 +104,7 @@ void ExportOnBlockchain(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
std::shared_ptr<Data::UniqueGift> gift,
|
std::shared_ptr<Data::UniqueGift> gift,
|
||||||
Data::SavedStarGiftId giftId,
|
Data::SavedStarGiftId giftId,
|
||||||
Fn<void()> waitFinished,
|
Fn<void()> boxShown,
|
||||||
Fn<void()> wentToUrl) {
|
Fn<void()> wentToUrl) {
|
||||||
struct State {
|
struct State {
|
||||||
bool loading = false;
|
bool loading = false;
|
||||||
|
@ -125,16 +126,14 @@ void ExportOnBlockchain(
|
||||||
tr::lng_gift_transfer_password_about(tr::now),
|
tr::lng_gift_transfer_password_about(tr::now),
|
||||||
});
|
});
|
||||||
if (box) {
|
if (box) {
|
||||||
waitFinished();
|
|
||||||
show->show(std::move(box));
|
show->show(std::move(box));
|
||||||
|
boxShown();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state->lifetime = session->api().cloudPassword().state(
|
state->lifetime = session->api().cloudPassword().state(
|
||||||
) | rpl::take(
|
) | rpl::take(
|
||||||
1
|
1
|
||||||
) | rpl::start_with_next([=](const Core::CloudPasswordState &pass) {
|
) | rpl::start_with_next([=](const Core::CloudPasswordState &pass) {
|
||||||
waitFinished();
|
|
||||||
|
|
||||||
auto fields = PasscodeBox::CloudFields::From(pass);
|
auto fields = PasscodeBox::CloudFields::From(pass);
|
||||||
fields.customTitle = tr::lng_gift_transfer_password_title();
|
fields.customTitle = tr::lng_gift_transfer_password_title();
|
||||||
fields.customDescription
|
fields.customDescription
|
||||||
|
@ -149,8 +148,8 @@ void ExportOnBlockchain(
|
||||||
Api::InputSavedStarGiftId(giftId),
|
Api::InputSavedStarGiftId(giftId),
|
||||||
result.result)
|
result.result)
|
||||||
).done([=](const ExportUrl &result) {
|
).done([=](const ExportUrl &result) {
|
||||||
const auto url = qs(result.data().vurl());
|
UrlClickHandler::Open(qs(result.data().vurl()));
|
||||||
show->show(Box(ConfirmExportBox, gift, url, wentToUrl));
|
wentToUrl();
|
||||||
if (box) {
|
if (box) {
|
||||||
box->closeBox();
|
box->closeBox();
|
||||||
}
|
}
|
||||||
|
@ -162,6 +161,7 @@ void ExportOnBlockchain(
|
||||||
}).send();
|
}).send();
|
||||||
});
|
});
|
||||||
show->show(Box<PasscodeBox>(session, fields));
|
show->show(Box<PasscodeBox>(session, fields));
|
||||||
|
boxShown();
|
||||||
});
|
});
|
||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
|
@ -182,17 +182,21 @@ void ExportOnBlockchain(
|
||||||
const auto left = (when > now) ? (when - now) : 0;
|
const auto left = (when > now) ? (when - now) : 0;
|
||||||
const auto hours = left ? std::max((left + 1800) / 3600, 1) : 0;
|
const auto hours = left ? std::max((left + 1800) / 3600, 1) : 0;
|
||||||
if (!hours) {
|
if (!hours) {
|
||||||
if (state->exporting) {
|
window->show(Box(ConfirmExportBox, gift, [=](Fn<void()> close) {
|
||||||
return;
|
if (state->exporting) {
|
||||||
}
|
return;
|
||||||
state->exporting = true;
|
|
||||||
ExportOnBlockchain(window, box, gift, giftId, [=] {
|
|
||||||
state->exporting = false;
|
|
||||||
}, [=] {
|
|
||||||
if (const auto strong = weak.data()) {
|
|
||||||
strong->closeBox();
|
|
||||||
}
|
}
|
||||||
});
|
state->exporting = true;
|
||||||
|
ExportOnBlockchain(window, box, gift, giftId, [=] {
|
||||||
|
state->exporting = false;
|
||||||
|
close();
|
||||||
|
}, [=] {
|
||||||
|
if (const auto strong = weak.data()) {
|
||||||
|
strong->closeBox();
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
});
|
||||||
|
}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window->show(Ui::MakeInformBox({
|
window->show(Ui::MakeInformBox({
|
||||||
|
|
Loading…
Add table
Reference in a new issue