mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added ability to create giveaways from giveaway box.
This commit is contained in:
parent
5e28b2d601
commit
85fdc04d48
1 changed files with 34 additions and 11 deletions
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "api/api_premium.h"
|
#include "api/api_premium.h"
|
||||||
#include "base/call_delayed.h"
|
#include "base/call_delayed.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
|
#include "countries/countries_instance.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
#include "info/boosts/giveaway/giveaway_list_controllers.h"
|
#include "info/boosts/giveaway/giveaway_list_controllers.h"
|
||||||
#include "info/boosts/giveaway/giveaway_type_row.h"
|
#include "info/boosts/giveaway/giveaway_type_row.h"
|
||||||
|
@ -521,13 +522,21 @@ void CreateGiveawayBox(
|
||||||
if (state->confirmButtonBusy) {
|
if (state->confirmButtonBusy) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (typeGroup->value() == GiveawayType::SpecificUsers) {
|
const auto type = typeGroup->value();
|
||||||
|
const auto isSpecific = (type == GiveawayType::SpecificUsers);
|
||||||
|
const auto isRandom = (type == GiveawayType::Random);
|
||||||
|
if (!isSpecific && !isRandom) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto invoice = state->apiOptions.invoice(
|
||||||
|
isSpecific
|
||||||
|
? state->selectedToAward.size()
|
||||||
|
: state->sliderValue.current(),
|
||||||
|
durationGroup->value());
|
||||||
|
if (isSpecific) {
|
||||||
if (state->selectedToAward.empty()) {
|
if (state->selectedToAward.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto invoice = state->apiOptions.invoice(
|
|
||||||
state->selectedToAward.size(),
|
|
||||||
durationGroup->value());
|
|
||||||
invoice.purpose = Payments::InvoicePremiumGiftCodeUsers{
|
invoice.purpose = Payments::InvoicePremiumGiftCodeUsers{
|
||||||
ranges::views::all(
|
ranges::views::all(
|
||||||
state->selectedToAward
|
state->selectedToAward
|
||||||
|
@ -537,14 +546,28 @@ void CreateGiveawayBox(
|
||||||
}) | ranges::to_vector,
|
}) | ranges::to_vector,
|
||||||
peer->asChannel(),
|
peer->asChannel(),
|
||||||
};
|
};
|
||||||
state->confirmButtonBusy = true;
|
} else if (isRandom) {
|
||||||
Payments::CheckoutProcess::Start(
|
invoice.purpose = Payments::InvoicePremiumGiftCodeGiveaway{
|
||||||
std::move(invoice),
|
.boostPeer = peer->asChannel(),
|
||||||
crl::guard(box, [=](auto) {
|
.additionalChannels = ranges::views::all(
|
||||||
state->confirmButtonBusy = false;
|
state->selectedToSubscribe
|
||||||
box->window()->setFocus();
|
) | ranges::views::transform([](
|
||||||
}));
|
const not_null<PeerData*> p) {
|
||||||
|
return not_null{ p->asChannel() };
|
||||||
|
}) | ranges::to_vector,
|
||||||
|
.countries = state->countriesValue.current(),
|
||||||
|
.untilDate = state->dateValue.current(),
|
||||||
|
.onlyNewSubscribers = (membersGroup->value()
|
||||||
|
== GiveawayType::OnlyNewMembers),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
state->confirmButtonBusy = true;
|
||||||
|
Payments::CheckoutProcess::Start(
|
||||||
|
std::move(invoice),
|
||||||
|
crl::guard(box, [=](auto) {
|
||||||
|
state->confirmButtonBusy = false;
|
||||||
|
box->window()->setFocus();
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
box->addButton(std::move(button));
|
box->addButton(std::move(button));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue