mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improved processing of giveaway creation after payment.
This commit is contained in:
parent
6ca777102c
commit
474fa56cc0
3 changed files with 24 additions and 10 deletions
|
@ -228,7 +228,8 @@ void AddPremiumTopBarWithDefaultTitleBar(
|
||||||
void CreateGiveawayBox(
|
void CreateGiveawayBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Info::Controller*> controller,
|
not_null<Info::Controller*> controller,
|
||||||
not_null<PeerData*> peer) {
|
not_null<PeerData*> peer,
|
||||||
|
Fn<void()> reloadOnDone) {
|
||||||
box->setWidth(st::boxWideWidth);
|
box->setWidth(st::boxWideWidth);
|
||||||
|
|
||||||
const auto weakWindow = base::make_weak(controller->parentController());
|
const auto weakWindow = base::make_weak(controller->parentController());
|
||||||
|
@ -790,12 +791,15 @@ void CreateGiveawayBox(
|
||||||
const auto show = box->uiShow();
|
const auto show = box->uiShow();
|
||||||
const auto weak = Ui::MakeWeak(box.get());
|
const auto weak = Ui::MakeWeak(box.get());
|
||||||
const auto done = [=](Payments::CheckoutResult result) {
|
const auto done = [=](Payments::CheckoutResult result) {
|
||||||
if (const auto strong = weak.data()) {
|
const auto isPaid = result == Payments::CheckoutResult::Paid;
|
||||||
state->confirmButtonBusy = false;
|
if (result == Payments::CheckoutResult::Pending || isPaid) {
|
||||||
strong->window()->setFocus();
|
if (const auto strong = weak.data()) {
|
||||||
strong->closeBox();
|
strong->window()->setFocus();
|
||||||
|
strong->closeBox();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (result == Payments::CheckoutResult::Paid) {
|
if (isPaid) {
|
||||||
|
reloadOnDone();
|
||||||
const auto filter = [=](const auto &...) {
|
const auto filter = [=](const auto &...) {
|
||||||
if (const auto window = weakWindow.get()) {
|
if (const auto window = weakWindow.get()) {
|
||||||
window->showSection(Info::Boosts::Make(peer));
|
window->showSection(Info::Boosts::Make(peer));
|
||||||
|
@ -822,6 +826,8 @@ void CreateGiveawayBox(
|
||||||
.adaptive = true,
|
.adaptive = true,
|
||||||
.filter = filter,
|
.filter = filter,
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
state->confirmButtonBusy = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Payments::CheckoutProcess::Start(std::move(invoice), done);
|
Payments::CheckoutProcess::Start(std::move(invoice), done);
|
||||||
|
|
|
@ -20,4 +20,5 @@ class GenericBox;
|
||||||
void CreateGiveawayBox(
|
void CreateGiveawayBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Info::Controller*> controller,
|
not_null<Info::Controller*> controller,
|
||||||
not_null<PeerData*> peer);
|
not_null<PeerData*> peer,
|
||||||
|
Fn<void()> reloadOnDone);
|
||||||
|
|
|
@ -216,7 +216,8 @@ void FillGetBoostsButton(
|
||||||
not_null<Ui::VerticalLayout*> content,
|
not_null<Ui::VerticalLayout*> content,
|
||||||
not_null<Controller*> controller,
|
not_null<Controller*> controller,
|
||||||
std::shared_ptr<Ui::Show> show,
|
std::shared_ptr<Ui::Show> show,
|
||||||
not_null<PeerData*> peer) {
|
not_null<PeerData*> peer,
|
||||||
|
Fn<void()> reloadOnDone) {
|
||||||
if (!Api::PremiumGiftCodeOptions(peer).giveawayGiftsPurchaseAvailable()) {
|
if (!Api::PremiumGiftCodeOptions(peer).giveawayGiftsPurchaseAvailable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -229,7 +230,7 @@ void FillGetBoostsButton(
|
||||||
tr::lng_boosts_get_boosts(),
|
tr::lng_boosts_get_boosts(),
|
||||||
st));
|
st));
|
||||||
button->setClickedCallback([=] {
|
button->setClickedCallback([=] {
|
||||||
show->showBox(Box(CreateGiveawayBox, controller, peer));
|
show->showBox(Box(CreateGiveawayBox, controller, peer, reloadOnDone));
|
||||||
});
|
});
|
||||||
Ui::CreateChild<Info::Profile::FloatingIcon>(
|
Ui::CreateChild<Info::Profile::FloatingIcon>(
|
||||||
button,
|
button,
|
||||||
|
@ -428,7 +429,13 @@ void InnerWidget::fill() {
|
||||||
::Settings::AddSkip(inner);
|
::Settings::AddSkip(inner);
|
||||||
::Settings::AddDividerText(inner, tr::lng_boosts_link_subtext());
|
::Settings::AddDividerText(inner, tr::lng_boosts_link_subtext());
|
||||||
|
|
||||||
FillGetBoostsButton(inner, _controller, _show, _peer);
|
const auto reloadOnDone = crl::guard(this, [=] {
|
||||||
|
while (Ui::VerticalLayout::count()) {
|
||||||
|
delete Ui::VerticalLayout::widgetAt(0);
|
||||||
|
}
|
||||||
|
load();
|
||||||
|
});
|
||||||
|
FillGetBoostsButton(inner, _controller, _show, _peer, reloadOnDone);
|
||||||
|
|
||||||
resizeToWidth(width());
|
resizeToWidth(width());
|
||||||
crl::on_main(this, [=]{ fakeShowed->fire({}); });
|
crl::on_main(this, [=]{ fakeShowed->fire({}); });
|
||||||
|
|
Loading…
Add table
Reference in a new issue