mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +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,
|
||||
.message = details.text,
|
||||
.user = peer->asUser(),
|
||||
.limitedCount = gift.limitedCount,
|
||||
.anonymous = details.anonymous,
|
||||
}, done, processNonPanelPaymentFormFactory);
|
||||
});
|
||||
|
|
|
@ -501,11 +501,13 @@ void Form::requestForm() {
|
|||
.currency = currency,
|
||||
.amount = amount,
|
||||
};
|
||||
const auto gift = std::get_if<InvoiceStarGift>(&_id.value);
|
||||
const auto formData = CreditsFormData{
|
||||
.id = _id,
|
||||
.formId = data.vform_id().v,
|
||||
.invoice = invoice,
|
||||
.inputInvoice = inputInvoice(),
|
||||
.starGiftLimitedCount = gift ? gift->limitedCount : 0,
|
||||
.starGiftForm = true,
|
||||
};
|
||||
_updates.fire(CreditsPaymentStarted{ .data = formData });
|
||||
|
|
|
@ -177,6 +177,7 @@ struct InvoiceStarGift {
|
|||
uint64 randomId = 0;
|
||||
TextWithEntities message;
|
||||
not_null<UserData*> user;
|
||||
int limitedCount = 0;
|
||||
bool anonymous = false;
|
||||
};
|
||||
|
||||
|
@ -198,6 +199,7 @@ struct CreditsFormData {
|
|||
PhotoData *photo = nullptr;
|
||||
InvoiceCredits invoice;
|
||||
MTPInputInvoice inputInvoice;
|
||||
int starGiftLimitedCount = 0;
|
||||
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/layers/generic_box.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_session_controller.h"
|
||||
|
||||
|
@ -59,7 +61,24 @@ void ProcessCreditsPayment(
|
|||
const auto done = [=](std::optional<QString> error) {
|
||||
const auto onstack = maybeReturnToBot;
|
||||
if (error) {
|
||||
show->showToast(*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);
|
||||
}
|
||||
if (onstack) {
|
||||
onstack(CheckoutResult::Failed);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue