mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-25 15:03:03 +02:00
Server-side min/max values for TON suggests.
This commit is contained in:
parent
9dfaac8582
commit
deb4c48551
3 changed files with 23 additions and 7 deletions
|
@ -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 {};
|
||||
}
|
||||
|
|
|
@ -166,6 +166,16 @@ int AppConfig::suggestedPostStarsMax() const {
|
|||
return get<int>(u"stars_suggested_post_amount_max"_q, 100'000);
|
||||
}
|
||||
|
||||
int64 AppConfig::suggestedPostNanoTonMin() const {
|
||||
return get<int64>(u"ton_suggested_post_amount_min"_q, 10'000'000LL);
|
||||
}
|
||||
|
||||
int64 AppConfig::suggestedPostNanoTonMax() const {
|
||||
return get<int64>(
|
||||
u"ton_suggested_post_amount_max"_q,
|
||||
10'000'000'000'000LL);
|
||||
}
|
||||
|
||||
int AppConfig::suggestedPostDelayMin() const {
|
||||
return get<int>(u"stars_suggested_post_future_min"_q, 300);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ public:
|
|||
return getDouble(key, fallback);
|
||||
} else if constexpr (std::is_same_v<Type, int>) {
|
||||
return int(base::SafeRound(getDouble(key, double(fallback))));
|
||||
} else if constexpr (std::is_same_v<Type, int64>) {
|
||||
return int64(base::SafeRound(getDouble(key, double(fallback))));
|
||||
} else if constexpr (std::is_same_v<Type, QString>) {
|
||||
return getString(key, fallback);
|
||||
} else if constexpr (std::is_same_v<Type, std::vector<QString>>) {
|
||||
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue