mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added api support to get credits gift options.
This commit is contained in:
parent
e760a0983f
commit
127f651d5e
1 changed files with 25 additions and 9 deletions
|
@ -134,12 +134,10 @@ rpl::producer<rpl::no_value, QString> CreditsTopupOptions::request() {
|
||||||
return [=](auto consumer) {
|
return [=](auto consumer) {
|
||||||
auto lifetime = rpl::lifetime();
|
auto lifetime = rpl::lifetime();
|
||||||
|
|
||||||
using TLOption = MTPStarsTopupOption;
|
const auto optionsFromTL = [](const auto &options) {
|
||||||
_api.request(MTPpayments_GetStarsTopupOptions(
|
return ranges::views::all(
|
||||||
)).done([=](const MTPVector<TLOption> &result) {
|
options
|
||||||
_options = ranges::views::all(
|
) | ranges::views::transform([=](const auto &option) {
|
||||||
result.v
|
|
||||||
) | ranges::views::transform([](const TLOption &option) {
|
|
||||||
return Data::CreditTopupOption{
|
return Data::CreditTopupOption{
|
||||||
.credits = option.data().vstars().v,
|
.credits = option.data().vstars().v,
|
||||||
.product = qs(
|
.product = qs(
|
||||||
|
@ -149,10 +147,28 @@ rpl::producer<rpl::no_value, QString> CreditsTopupOptions::request() {
|
||||||
.extended = option.data().is_extended(),
|
.extended = option.data().is_extended(),
|
||||||
};
|
};
|
||||||
}) | ranges::to_vector;
|
}) | ranges::to_vector;
|
||||||
consumer.put_done();
|
};
|
||||||
}).fail([=](const MTP::Error &error) {
|
const auto fail = [=](const MTP::Error &error) {
|
||||||
consumer.put_error_copy(error.type());
|
consumer.put_error_copy(error.type());
|
||||||
}).send();
|
};
|
||||||
|
|
||||||
|
if (_peer->isSelf()) {
|
||||||
|
using TLOption = MTPStarsTopupOption;
|
||||||
|
_api.request(MTPpayments_GetStarsTopupOptions(
|
||||||
|
)).done([=](const MTPVector<TLOption> &result) {
|
||||||
|
_options = optionsFromTL(result.v);
|
||||||
|
consumer.put_done();
|
||||||
|
}).fail(fail).send();
|
||||||
|
} else if (const auto user = _peer->asUser()) {
|
||||||
|
using TLOption = MTPStarsGiftOption;
|
||||||
|
_api.request(MTPpayments_GetStarsGiftOptions(
|
||||||
|
MTP_flags(MTPpayments_GetStarsGiftOptions::Flag::f_user_id),
|
||||||
|
user->inputUser
|
||||||
|
)).done([=](const MTPVector<TLOption> &result) {
|
||||||
|
_options = optionsFromTL(result.v);
|
||||||
|
consumer.put_done();
|
||||||
|
}).fail(fail).send();
|
||||||
|
}
|
||||||
|
|
||||||
return lifetime;
|
return lifetime;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue