diff --git a/Telegram/SourceFiles/info/boosts/create_giveaway_box.cpp b/Telegram/SourceFiles/info/boosts/create_giveaway_box.cpp index f34e3f7da..1c830c08f 100644 --- a/Telegram/SourceFiles/info/boosts/create_giveaway_box.cpp +++ b/Telegram/SourceFiles/info/boosts/create_giveaway_box.cpp @@ -228,7 +228,8 @@ void AddPremiumTopBarWithDefaultTitleBar( void CreateGiveawayBox( not_null box, not_null controller, - not_null peer) { + not_null peer, + Fn reloadOnDone) { box->setWidth(st::boxWideWidth); const auto weakWindow = base::make_weak(controller->parentController()); @@ -790,12 +791,15 @@ void CreateGiveawayBox( const auto show = box->uiShow(); const auto weak = Ui::MakeWeak(box.get()); const auto done = [=](Payments::CheckoutResult result) { - if (const auto strong = weak.data()) { - state->confirmButtonBusy = false; - strong->window()->setFocus(); - strong->closeBox(); + const auto isPaid = result == Payments::CheckoutResult::Paid; + if (result == Payments::CheckoutResult::Pending || isPaid) { + if (const auto strong = weak.data()) { + strong->window()->setFocus(); + strong->closeBox(); + } } - if (result == Payments::CheckoutResult::Paid) { + if (isPaid) { + reloadOnDone(); const auto filter = [=](const auto &...) { if (const auto window = weakWindow.get()) { window->showSection(Info::Boosts::Make(peer)); @@ -822,6 +826,8 @@ void CreateGiveawayBox( .adaptive = true, .filter = filter, }); + } else { + state->confirmButtonBusy = false; } }; Payments::CheckoutProcess::Start(std::move(invoice), done); diff --git a/Telegram/SourceFiles/info/boosts/create_giveaway_box.h b/Telegram/SourceFiles/info/boosts/create_giveaway_box.h index 7463732dc..d31383dc7 100644 --- a/Telegram/SourceFiles/info/boosts/create_giveaway_box.h +++ b/Telegram/SourceFiles/info/boosts/create_giveaway_box.h @@ -20,4 +20,5 @@ class GenericBox; void CreateGiveawayBox( not_null box, not_null controller, - not_null peer); + not_null peer, + Fn reloadOnDone); diff --git a/Telegram/SourceFiles/info/boosts/info_boosts_inner_widget.cpp b/Telegram/SourceFiles/info/boosts/info_boosts_inner_widget.cpp index 2f85dd9a7..2cfebee08 100644 --- a/Telegram/SourceFiles/info/boosts/info_boosts_inner_widget.cpp +++ b/Telegram/SourceFiles/info/boosts/info_boosts_inner_widget.cpp @@ -216,7 +216,8 @@ void FillGetBoostsButton( not_null content, not_null controller, std::shared_ptr show, - not_null peer) { + not_null peer, + Fn reloadOnDone) { if (!Api::PremiumGiftCodeOptions(peer).giveawayGiftsPurchaseAvailable()) { return; } @@ -229,7 +230,7 @@ void FillGetBoostsButton( tr::lng_boosts_get_boosts(), st)); button->setClickedCallback([=] { - show->showBox(Box(CreateGiveawayBox, controller, peer)); + show->showBox(Box(CreateGiveawayBox, controller, peer, reloadOnDone)); }); Ui::CreateChild( button, @@ -428,7 +429,13 @@ void InnerWidget::fill() { ::Settings::AddSkip(inner); ::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()); crl::on_main(this, [=]{ fakeShowed->fire({}); });