Added support of maximum amount of credits to withdraw from app config.

This commit is contained in:
23rd 2025-06-29 22:34:18 +03:00
parent 388803ffdb
commit c93e948bb3
5 changed files with 18 additions and 2 deletions

View file

@ -6577,6 +6577,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_bot_earn_learn_credits_out_about" = "You can withdraw Stars using Fragment, or use Stars to advertise your bot. {link}"; "lng_bot_earn_learn_credits_out_about" = "You can withdraw Stars using Fragment, or use Stars to advertise your bot. {link}";
"lng_self_earn_learn_credits_out_about" = "You can withdraw from 10 Stars using Fragment. {link}"; "lng_self_earn_learn_credits_out_about" = "You can withdraw from 10 Stars using Fragment. {link}";
"lng_bot_earn_out_ph" = "Enter amount to withdraw"; "lng_bot_earn_out_ph" = "Enter amount to withdraw";
"lng_bot_earn_out_ph_max" = "Enter amount to withdraw (max. {amount})";
"lng_bot_earn_balance_password_title" = "Two-step verification"; "lng_bot_earn_balance_password_title" = "Two-step verification";
"lng_bot_earn_balance_password_description" = "Please enter your password to collect."; "lng_bot_earn_balance_password_description" = "Please enter your password to collect.";
"lng_bot_earn_credits_out_minimal" = "You cannot withdraw less than {link}."; "lng_bot_earn_credits_out_minimal" = "You cannot withdraw less than {link}.";

View file

@ -89,6 +89,10 @@ int AppConfig::starrefCommissionMax() const {
return get<int>(u"starref_max_commission_permille"_q, 900); return get<int>(u"starref_max_commission_permille"_q, 900);
} }
int AppConfig::starsWithdrawMax() const {
return get<int>(u"stars_revenue_withdrawal_max"_q, 100);
}
float64 AppConfig::starsWithdrawRate() const { float64 AppConfig::starsWithdrawRate() const {
return get<float64>(u"stars_usd_withdraw_rate_x1000"_q, 1300) / 1000.; return get<float64>(u"stars_usd_withdraw_rate_x1000"_q, 1300) / 1000.;
} }

View file

@ -69,6 +69,7 @@ public:
[[nodiscard]] int starrefCommissionMin() const; [[nodiscard]] int starrefCommissionMin() const;
[[nodiscard]] int starrefCommissionMax() const; [[nodiscard]] int starrefCommissionMax() const;
[[nodiscard]] int starsWithdrawMax() const;
[[nodiscard]] float64 starsWithdrawRate() const; [[nodiscard]] float64 starsWithdrawRate() const;
[[nodiscard]] float64 currencyWithdrawRate() const; [[nodiscard]] float64 currencyWithdrawRate() const;
[[nodiscard]] bool paidMessagesAvailable() const; [[nodiscard]] bool paidMessagesAvailable() const;

View file

@ -2615,9 +2615,15 @@ void AddWithdrawalWidget(
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>( object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
container, container,
object_ptr<Ui::VerticalLayout>(container))); object_ptr<Ui::VerticalLayout>(container)));
const auto starsWithdrawMax = CreditsAmount(
controller->session().appConfig().starsWithdrawMax());
const auto input = Ui::AddInputFieldForCredits( const auto input = Ui::AddInputFieldForCredits(
withdrawalWrap->entity(), withdrawalWrap->entity(),
rpl::duplicate(availableBalanceValue)); rpl::duplicate(
availableBalanceValue
) | rpl::map([=](CreditsAmount amount) {
return (amount > starsWithdrawMax) ? starsWithdrawMax : amount;
}));
Ui::AddSkip(withdrawalWrap->entity()); Ui::AddSkip(withdrawalWrap->entity());
Ui::AddSkip(withdrawalWrap->entity()); Ui::AddSkip(withdrawalWrap->entity());

View file

@ -175,7 +175,11 @@ not_null<MaskedInputField*> AddInputFieldForCredits(
const auto input = CreateChild<NumberInput>( const auto input = CreateChild<NumberInput>(
inputContainer, inputContainer,
st, st,
tr::lng_bot_earn_out_ph(), tr::lng_bot_earn_out_ph_max(
lt_amount,
currentValue.value() | rpl::map([](CreditsAmount amount) {
return QString::number(amount.whole());
})),
QString::number(currentValue.current().whole()), QString::number(currentValue.current().whole()),
currentValue.current().whole()); currentValue.current().whole());
rpl::duplicate( rpl::duplicate(