mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Respected accessibility of premium for credits purchasing.
This commit is contained in:
parent
9a5923676a
commit
cd7507fb23
3 changed files with 23 additions and 6 deletions
|
@ -2328,6 +2328,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_credits_small_balance_title#one" = "{count} Star Needed";
|
||||
"lng_credits_small_balance_title#other" = "{count} Stars Needed";
|
||||
"lng_credits_small_balance_about" = "Buy **Stars** and use them on **{bot}** and other miniapps.";
|
||||
"lng_credits_purchase_blocked" = "Sorry, you can't purchase this item with Telegram Stars.";
|
||||
|
||||
"lng_location_title" = "Location";
|
||||
"lng_location_about" = "Display the location of your business on your account.";
|
||||
|
|
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_user.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "mainwidget.h"
|
||||
#include "payments/payments_checkout_process.h" // NonPanelPaymentForm.
|
||||
|
@ -80,13 +81,19 @@ Fn<void(NonPanelPaymentForm)> ProcessNonPanelPaymentFormFactory(
|
|||
- int64(slice.balance);
|
||||
if (creditsNeeded <= 0) {
|
||||
sendBox();
|
||||
} else {
|
||||
} else if (strong->session().premiumPossible()) {
|
||||
strong->uiShow()->show(Box(
|
||||
Settings::SmallBalanceBox,
|
||||
strong,
|
||||
creditsNeeded,
|
||||
form->botId,
|
||||
sendBox));
|
||||
} else {
|
||||
strong->uiShow()->showToast(
|
||||
tr::lng_credits_purchase_blocked(tr::now));
|
||||
if (maybeReturnToBot) {
|
||||
maybeReturnToBot(CheckoutResult::Failed);
|
||||
}
|
||||
}
|
||||
}
|
||||
lifetime->destroy();
|
||||
|
|
|
@ -286,11 +286,20 @@ void FillCreditOptions(
|
|||
const auto apiCredits = content->lifetime().make_state<ApiOptions>(
|
||||
controller->session().user());
|
||||
|
||||
apiCredits->request(
|
||||
) | rpl::start_with_error_done([=](const QString &error) {
|
||||
controller->showToast(error);
|
||||
}, [=] {
|
||||
fill(apiCredits->options());
|
||||
if (controller->session().premiumPossible()) {
|
||||
apiCredits->request(
|
||||
) | rpl::start_with_error_done([=](const QString &error) {
|
||||
controller->showToast(error);
|
||||
}, [=] {
|
||||
fill(apiCredits->options());
|
||||
}, content->lifetime());
|
||||
}
|
||||
|
||||
controller->session().premiumPossibleValue(
|
||||
) | rpl::start_with_next([=](bool premiumPossible) {
|
||||
if (!premiumPossible) {
|
||||
fill({});
|
||||
}
|
||||
}, content->lifetime());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue