Skip to content

Commit 9df9835

Browse files
committed
Show correct error on gift limit reaching.
1 parent c0c5ad2 commit 9df9835

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

Telegram/SourceFiles/boxes/star_gift_box.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,6 +2041,7 @@ void SendGift(
20412041
.message = details.text,
20422042
.recipient = peer,
20432043
.limitedCount = gift.info.limitedCount,
2044+
.perUserLimit = gift.info.perUserTotal,
20442045
.anonymous = details.anonymous,
20452046
.upgraded = details.upgraded,
20462047
}, done, processNonPanelPaymentFormFactory);
@@ -2952,6 +2953,16 @@ void SendGiftBox(
29522953
[=] { state->resaleRequestingId = 0; });
29532954
} else if (star && IsSoldOut(star->info)) {
29542955
window->show(Box(SoldOutBox, window, *star));
2956+
} else if (star
2957+
&& star->info.perUserTotal
2958+
&& !star->info.perUserRemains) {
2959+
window->showToast({
2960+
.text = tr::lng_gift_sent_finished(
2961+
tr::now,
2962+
lt_count,
2963+
star->info.perUserTotal,
2964+
Ui::Text::RichLangValue),
2965+
});
29552966
} else {
29562967
send();
29572968
}

Telegram/SourceFiles/payments/payments_form.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ void Form::requestForm() {
533533
.invoice = invoice,
534534
.inputInvoice = inputInvoice(),
535535
.starGiftLimitedCount = gift ? gift->limitedCount : 0,
536+
.starGiftPerUserLimit = gift ? gift->perUserLimit : 0,
536537
.starGiftForm = true,
537538
};
538539
_updates.fire(CreditsPaymentStarted{ .data = formData });

Telegram/SourceFiles/payments/payments_form.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ struct InvoiceStarGift {
179179
TextWithEntities message;
180180
not_null<PeerData*> recipient;
181181
int limitedCount = 0;
182+
int perUserLimit = 0;
182183
bool anonymous = false;
183184
bool upgraded = false;
184185
};
@@ -202,6 +203,7 @@ struct CreditsFormData {
202203
InvoiceCredits invoice;
203204
MTPInputInvoice inputInvoice;
204205
int starGiftLimitedCount = 0;
206+
int starGiftPerUserLimit = 0;
205207
bool starGiftForm = false;
206208
};
207209

Telegram/SourceFiles/payments/payments_non_panel_process.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ void ProcessCreditsPayment(
7777
show->showToast(
7878
tr::lng_gift_sold_out_title(tr::now));
7979
}
80+
} else if (*error == u"STARGIFT_USER_USAGE_LIMITED"_q) {
81+
show->showToast({
82+
.text = tr::lng_gift_sent_finished(
83+
tr::now,
84+
lt_count,
85+
std::max(form->starGiftPerUserLimit, 1),
86+
Ui::Text::RichLangValue),
87+
});
8088
} else {
8189
show->showToast(*error);
8290
}

0 commit comments

Comments
 (0)