mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Show correct error on gift limit reaching.
This commit is contained in:
@@ -2041,6 +2041,7 @@ void SendGift(
|
||||
.message = details.text,
|
||||
.recipient = peer,
|
||||
.limitedCount = gift.info.limitedCount,
|
||||
.perUserLimit = gift.info.perUserTotal,
|
||||
.anonymous = details.anonymous,
|
||||
.upgraded = details.upgraded,
|
||||
}, done, processNonPanelPaymentFormFactory);
|
||||
@@ -2952,6 +2953,16 @@ void SendGiftBox(
|
||||
[=] { state->resaleRequestingId = 0; });
|
||||
} else if (star && IsSoldOut(star->info)) {
|
||||
window->show(Box(SoldOutBox, window, *star));
|
||||
} else if (star
|
||||
&& star->info.perUserTotal
|
||||
&& !star->info.perUserRemains) {
|
||||
window->showToast({
|
||||
.text = tr::lng_gift_sent_finished(
|
||||
tr::now,
|
||||
lt_count,
|
||||
star->info.perUserTotal,
|
||||
Ui::Text::RichLangValue),
|
||||
});
|
||||
} else {
|
||||
send();
|
||||
}
|
||||
|
||||
@@ -533,6 +533,7 @@ void Form::requestForm() {
|
||||
.invoice = invoice,
|
||||
.inputInvoice = inputInvoice(),
|
||||
.starGiftLimitedCount = gift ? gift->limitedCount : 0,
|
||||
.starGiftPerUserLimit = gift ? gift->perUserLimit : 0,
|
||||
.starGiftForm = true,
|
||||
};
|
||||
_updates.fire(CreditsPaymentStarted{ .data = formData });
|
||||
|
||||
@@ -179,6 +179,7 @@ struct InvoiceStarGift {
|
||||
TextWithEntities message;
|
||||
not_null<PeerData*> recipient;
|
||||
int limitedCount = 0;
|
||||
int perUserLimit = 0;
|
||||
bool anonymous = false;
|
||||
bool upgraded = false;
|
||||
};
|
||||
@@ -202,6 +203,7 @@ struct CreditsFormData {
|
||||
InvoiceCredits invoice;
|
||||
MTPInputInvoice inputInvoice;
|
||||
int starGiftLimitedCount = 0;
|
||||
int starGiftPerUserLimit = 0;
|
||||
bool starGiftForm = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -77,6 +77,14 @@ void ProcessCreditsPayment(
|
||||
show->showToast(
|
||||
tr::lng_gift_sold_out_title(tr::now));
|
||||
}
|
||||
} else if (*error == u"STARGIFT_USER_USAGE_LIMITED"_q) {
|
||||
show->showToast({
|
||||
.text = tr::lng_gift_sent_finished(
|
||||
tr::now,
|
||||
lt_count,
|
||||
std::max(form->starGiftPerUserLimit, 1),
|
||||
Ui::Text::RichLangValue),
|
||||
});
|
||||
} else {
|
||||
show->showToast(*error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user