diff --git a/Telegram/SourceFiles/boxes/star_gift_box.cpp b/Telegram/SourceFiles/boxes/star_gift_box.cpp index 7d37a999c2..cbc8f707ec 100644 --- a/Telegram/SourceFiles/boxes/star_gift_box.cpp +++ b/Telegram/SourceFiles/boxes/star_gift_box.cpp @@ -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(); } diff --git a/Telegram/SourceFiles/payments/payments_form.cpp b/Telegram/SourceFiles/payments/payments_form.cpp index f0b46dd21d..ff005327ad 100644 --- a/Telegram/SourceFiles/payments/payments_form.cpp +++ b/Telegram/SourceFiles/payments/payments_form.cpp @@ -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 }); diff --git a/Telegram/SourceFiles/payments/payments_form.h b/Telegram/SourceFiles/payments/payments_form.h index 598f9a23d8..f857ce500d 100644 --- a/Telegram/SourceFiles/payments/payments_form.h +++ b/Telegram/SourceFiles/payments/payments_form.h @@ -179,6 +179,7 @@ struct InvoiceStarGift { TextWithEntities message; not_null 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; }; diff --git a/Telegram/SourceFiles/payments/payments_non_panel_process.cpp b/Telegram/SourceFiles/payments/payments_non_panel_process.cpp index d63b505a98..09b3bc1f50 100644 --- a/Telegram/SourceFiles/payments/payments_non_panel_process.cpp +++ b/Telegram/SourceFiles/payments/payments_non_panel_process.cpp @@ -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); }