mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Check gift sold out error on sending.
This commit is contained in:
parent
db475ef0b4
commit
1a0fd35f36
4 changed files with 25 additions and 1 deletions
|
@ -842,6 +842,7 @@ void SendGift(
|
||||||
.randomId = details.randomId,
|
.randomId = details.randomId,
|
||||||
.message = details.text,
|
.message = details.text,
|
||||||
.user = peer->asUser(),
|
.user = peer->asUser(),
|
||||||
|
.limitedCount = gift.limitedCount,
|
||||||
.anonymous = details.anonymous,
|
.anonymous = details.anonymous,
|
||||||
}, done, processNonPanelPaymentFormFactory);
|
}, done, processNonPanelPaymentFormFactory);
|
||||||
});
|
});
|
||||||
|
|
|
@ -501,11 +501,13 @@ void Form::requestForm() {
|
||||||
.currency = currency,
|
.currency = currency,
|
||||||
.amount = amount,
|
.amount = amount,
|
||||||
};
|
};
|
||||||
|
const auto gift = std::get_if<InvoiceStarGift>(&_id.value);
|
||||||
const auto formData = CreditsFormData{
|
const auto formData = CreditsFormData{
|
||||||
.id = _id,
|
.id = _id,
|
||||||
.formId = data.vform_id().v,
|
.formId = data.vform_id().v,
|
||||||
.invoice = invoice,
|
.invoice = invoice,
|
||||||
.inputInvoice = inputInvoice(),
|
.inputInvoice = inputInvoice(),
|
||||||
|
.starGiftLimitedCount = gift ? gift->limitedCount : 0,
|
||||||
.starGiftForm = true,
|
.starGiftForm = true,
|
||||||
};
|
};
|
||||||
_updates.fire(CreditsPaymentStarted{ .data = formData });
|
_updates.fire(CreditsPaymentStarted{ .data = formData });
|
||||||
|
|
|
@ -177,6 +177,7 @@ struct InvoiceStarGift {
|
||||||
uint64 randomId = 0;
|
uint64 randomId = 0;
|
||||||
TextWithEntities message;
|
TextWithEntities message;
|
||||||
not_null<UserData*> user;
|
not_null<UserData*> user;
|
||||||
|
int limitedCount = 0;
|
||||||
bool anonymous = false;
|
bool anonymous = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -198,6 +199,7 @@ struct CreditsFormData {
|
||||||
PhotoData *photo = nullptr;
|
PhotoData *photo = nullptr;
|
||||||
InvoiceCredits invoice;
|
InvoiceCredits invoice;
|
||||||
MTPInputInvoice inputInvoice;
|
MTPInputInvoice inputInvoice;
|
||||||
|
int starGiftLimitedCount = 0;
|
||||||
bool starGiftForm = false;
|
bool starGiftForm = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/boxes/boost_box.h" // Ui::StartFireworks.
|
#include "ui/boxes/boost_box.h" // Ui::StartFireworks.
|
||||||
#include "ui/layers/generic_box.h"
|
#include "ui/layers/generic_box.h"
|
||||||
#include "ui/text/format_values.h"
|
#include "ui/text/format_values.h"
|
||||||
|
#include "ui/text/text_utilities.h"
|
||||||
|
#include "ui/toast/toast.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
|
||||||
|
@ -59,7 +61,24 @@ void ProcessCreditsPayment(
|
||||||
const auto done = [=](std::optional<QString> error) {
|
const auto done = [=](std::optional<QString> error) {
|
||||||
const auto onstack = maybeReturnToBot;
|
const auto onstack = maybeReturnToBot;
|
||||||
if (error) {
|
if (error) {
|
||||||
|
if (*error == u"STARGIFT_USAGE_LIMITED"_q) {
|
||||||
|
if (form->starGiftLimitedCount) {
|
||||||
|
show->showToast({
|
||||||
|
.title = tr::lng_gift_sold_out_title(
|
||||||
|
tr::now),
|
||||||
|
.text = tr::lng_gift_sold_out_text(
|
||||||
|
tr::now,
|
||||||
|
lt_count_decimal,
|
||||||
|
form->starGiftLimitedCount,
|
||||||
|
Ui::Text::RichLangValue),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
show->showToast(
|
||||||
|
tr::lng_gift_sold_out_title(tr::now));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
show->showToast(*error);
|
show->showToast(*error);
|
||||||
|
}
|
||||||
if (onstack) {
|
if (onstack) {
|
||||||
onstack(CheckoutResult::Failed);
|
onstack(CheckoutResult::Failed);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue