diff --git a/Telegram/SourceFiles/history/view/controls/history_view_suggest_options.cpp b/Telegram/SourceFiles/history/view/controls/history_view_suggest_options.cpp index 42a4c3a949..2a7310ce2d 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_suggest_options.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_suggest_options.cpp @@ -118,7 +118,10 @@ void ChooseSuggestPriceBox( session->credits().load(); session->credits().tonLoad(); } - const auto limit = session->appConfig().suggestedPostStarsMax(); + const auto starsMin = 0; + const auto starsMax = session->appConfig().suggestedPostStarsMax(); + const auto nanoTonMin = session->appConfig().suggestedPostNanoTonMin(); + const auto nanoTonMax = session->appConfig().suggestedPostNanoTonMax(); box->setStyle(st::suggestPriceBox); box->setTitle((args.mode == SuggestMode::New) @@ -264,7 +267,7 @@ void ChooseSuggestPriceBox( ((args.value.exists && args.value.priceWhole && !args.value.ton) ? QString::number(args.value.priceWhole) : QString()), - limit); + starsMax); const auto starsField = ownedStarsField.data(); const auto starsIcon = makeIcon(starsField, manager->creditsEmoji()); @@ -343,17 +346,16 @@ void ChooseSuggestPriceBox( if (ton) { const auto text = tonField->getLastText(); const auto now = Ui::ParseTonAmountString(text); - if (now && ((*now < 0) || (*now > limit * Ui::kNanosInOne))) { - tonField->showError(); - return {}; - } else if (!now && !text.isEmpty()) { + if (now + && *now + && ((*now < nanoTonMin) || (*now > nanoTonMax))) { tonField->showError(); return {}; } nanos = now.value_or(0); } else { const auto now = starsField->getLastText().toLongLong(); - if (now < 0 || now > limit) { + if (now < starsMin || now > starsMax) { starsField->showError(); return {}; } diff --git a/Telegram/SourceFiles/main/main_app_config.cpp b/Telegram/SourceFiles/main/main_app_config.cpp index 3b9c79ea26..9d6377e11d 100644 --- a/Telegram/SourceFiles/main/main_app_config.cpp +++ b/Telegram/SourceFiles/main/main_app_config.cpp @@ -166,6 +166,16 @@ int AppConfig::suggestedPostStarsMax() const { return get(u"stars_suggested_post_amount_max"_q, 100'000); } +int64 AppConfig::suggestedPostNanoTonMin() const { + return get(u"ton_suggested_post_amount_min"_q, 10'000'000LL); +} + +int64 AppConfig::suggestedPostNanoTonMax() const { + return get( + u"ton_suggested_post_amount_max"_q, + 10'000'000'000'000LL); +} + int AppConfig::suggestedPostDelayMin() const { return get(u"stars_suggested_post_future_min"_q, 300); } diff --git a/Telegram/SourceFiles/main/main_app_config.h b/Telegram/SourceFiles/main/main_app_config.h index 0d9a4f6fbc..1fb4ab99e1 100644 --- a/Telegram/SourceFiles/main/main_app_config.h +++ b/Telegram/SourceFiles/main/main_app_config.h @@ -31,6 +31,8 @@ public: return getDouble(key, fallback); } else if constexpr (std::is_same_v) { return int(base::SafeRound(getDouble(key, double(fallback)))); + } else if constexpr (std::is_same_v) { + return int64(base::SafeRound(getDouble(key, double(fallback)))); } else if constexpr (std::is_same_v) { return getString(key, fallback); } else if constexpr (std::is_same_v>) { @@ -89,6 +91,8 @@ public: [[nodiscard]] int todoListItemTextLimit() const; [[nodiscard]] int suggestedPostStarsMax() const; + [[nodiscard]] int64 suggestedPostNanoTonMin() const; + [[nodiscard]] int64 suggestedPostNanoTonMax() const; [[nodiscard]] int suggestedPostDelayMin() const; [[nodiscard]] int suggestedPostDelayMax() const;