mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Add confirmation for prepared giveaway start.
This commit is contained in:
parent
ef1b197771
commit
639a82ce28
4 changed files with 25 additions and 5 deletions
|
@ -2116,6 +2116,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_giveaway_users_about" = "Choose if you want to limit the giveaway only to those who joined the channel after the giveaway started or to users from specific countries.";
|
||||
"lng_giveaway_start" = "Start Giveaway";
|
||||
"lng_giveaway_award" = "Gift Premium";
|
||||
"lng_giveaway_start_sure" = "Are you sure you want to start this prepaid giveaway now? This action cannot be undone.";
|
||||
"lng_giveaway_date_title" = "Date when giveaway ends";
|
||||
"lng_giveaway_date" = "Date and Time";
|
||||
"lng_giveaway_date_about#one" = "Choose when {count} subscriber of your channel will be randomly selected to receive Telegram Premium.";
|
||||
|
|
|
@ -518,10 +518,9 @@ rpl::producer<rpl::no_value, QString> Boosts::request() {
|
|||
? (100. * premiumMemberCount / participantCount)
|
||||
: 0;
|
||||
|
||||
const auto slots = data.vmy_boost_slots();
|
||||
_boostStatus.overview = Data::BoostsOverview{
|
||||
.mine = (data.vmy_boost_slots()
|
||||
? data.vmy_boost_slots()->v.size()
|
||||
: 0),
|
||||
.mine = slots ? int(slots->v.size()) : 0,
|
||||
.level = std::max(data.vlevel().v, 0),
|
||||
.boostCount = std::max(
|
||||
data.vboosts().v,
|
||||
|
|
|
@ -413,7 +413,7 @@ Ui::BoostCounters ParseBoostCounters(
|
|||
.boosts = data.vboosts().v,
|
||||
.thisLevelBoosts = data.vcurrent_level_boosts().v,
|
||||
.nextLevelBoosts = data.vnext_level_boosts().value_or_empty(),
|
||||
.mine = slots ? slots->v.size() : 0,
|
||||
.mine = slots ? int(slots->v.size()) : 0,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_premium.h" // Settings::ShowPremium
|
||||
#include "ui/boxes/choose_date_time.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/effects/premium_graphics.h"
|
||||
#include "ui/effects/premium_top_bar.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
|
@ -908,18 +909,37 @@ void CreateGiveawayBox(
|
|||
state->confirmButtonBusy = false;
|
||||
}
|
||||
};
|
||||
if (prepaid) {
|
||||
const auto startPrepaid = [=](Fn<void()> close) {
|
||||
if (!weak) {
|
||||
close();
|
||||
return;
|
||||
}
|
||||
state->apiOptions.applyPrepaid(
|
||||
invoice,
|
||||
prepaid->id
|
||||
) | rpl::start_with_error_done([=](const QString &error) {
|
||||
if (const auto window = weakWindow.get()) {
|
||||
window->uiShow()->showToast(error);
|
||||
close();
|
||||
done(Payments::CheckoutResult::Cancelled);
|
||||
}
|
||||
}, [=] {
|
||||
close();
|
||||
done(Payments::CheckoutResult::Paid);
|
||||
}, box->lifetime());
|
||||
};
|
||||
if (prepaid) {
|
||||
const auto cancel = [=](Fn<void()> close) {
|
||||
if (weak) {
|
||||
state->confirmButtonBusy = false;
|
||||
}
|
||||
close();
|
||||
};
|
||||
show->show(Ui::MakeConfirmBox({
|
||||
.text = tr::lng_giveaway_start_sure(tr::now),
|
||||
.confirmed = startPrepaid,
|
||||
.cancelled = cancel,
|
||||
}));
|
||||
} else {
|
||||
Payments::CheckoutProcess::Start(std::move(invoice), done);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue