mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-26 15:33:02 +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().load();
|
||||||
session->credits().tonLoad();
|
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->setStyle(st::suggestPriceBox);
|
||||||
box->setTitle((args.mode == SuggestMode::New)
|
box->setTitle((args.mode == SuggestMode::New)
|
||||||
|
@ -264,7 +267,7 @@ void ChooseSuggestPriceBox(
|
||||||
((args.value.exists && args.value.priceWhole && !args.value.ton)
|
((args.value.exists && args.value.priceWhole && !args.value.ton)
|
||||||
? QString::number(args.value.priceWhole)
|
? QString::number(args.value.priceWhole)
|
||||||
: QString()),
|
: QString()),
|
||||||
limit);
|
starsMax);
|
||||||
const auto starsField = ownedStarsField.data();
|
const auto starsField = ownedStarsField.data();
|
||||||
const auto starsIcon = makeIcon(starsField, manager->creditsEmoji());
|
const auto starsIcon = makeIcon(starsField, manager->creditsEmoji());
|
||||||
|
|
||||||
|
@ -343,17 +346,16 @@ void ChooseSuggestPriceBox(
|
||||||
if (ton) {
|
if (ton) {
|
||||||
const auto text = tonField->getLastText();
|
const auto text = tonField->getLastText();
|
||||||
const auto now = Ui::ParseTonAmountString(text);
|
const auto now = Ui::ParseTonAmountString(text);
|
||||||
if (now && ((*now < 0) || (*now > limit * Ui::kNanosInOne))) {
|
if (now
|
||||||
tonField->showError();
|
&& *now
|
||||||
return {};
|
&& ((*now < nanoTonMin) || (*now > nanoTonMax))) {
|
||||||
} else if (!now && !text.isEmpty()) {
|
|
||||||
tonField->showError();
|
tonField->showError();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
nanos = now.value_or(0);
|
nanos = now.value_or(0);
|
||||||
} else {
|
} else {
|
||||||
const auto now = starsField->getLastText().toLongLong();
|
const auto now = starsField->getLastText().toLongLong();
|
||||||
if (now < 0 || now > limit) {
|
if (now < starsMin || now > starsMax) {
|
||||||
starsField->showError();
|
starsField->showError();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,6 +166,16 @@ int AppConfig::suggestedPostStarsMax() const {
|
||||||
return get<int>(u"stars_suggested_post_amount_max"_q, 100'000);
|
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 {
|
int AppConfig::suggestedPostDelayMin() const {
|
||||||
return get<int>(u"stars_suggested_post_future_min"_q, 300);
|
return get<int>(u"stars_suggested_post_future_min"_q, 300);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@ public:
|
||||||
return getDouble(key, fallback);
|
return getDouble(key, fallback);
|
||||||
} else if constexpr (std::is_same_v<Type, int>) {
|
} else if constexpr (std::is_same_v<Type, int>) {
|
||||||
return int(base::SafeRound(getDouble(key, double(fallback))));
|
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>) {
|
} else if constexpr (std::is_same_v<Type, QString>) {
|
||||||
return getString(key, fallback);
|
return getString(key, fallback);
|
||||||
} else if constexpr (std::is_same_v<Type, std::vector<QString>>) {
|
} else if constexpr (std::is_same_v<Type, std::vector<QString>>) {
|
||||||
|
@ -89,6 +91,8 @@ public:
|
||||||
[[nodiscard]] int todoListItemTextLimit() const;
|
[[nodiscard]] int todoListItemTextLimit() const;
|
||||||
|
|
||||||
[[nodiscard]] int suggestedPostStarsMax() const;
|
[[nodiscard]] int suggestedPostStarsMax() const;
|
||||||
|
[[nodiscard]] int64 suggestedPostNanoTonMin() const;
|
||||||
|
[[nodiscard]] int64 suggestedPostNanoTonMax() const;
|
||||||
[[nodiscard]] int suggestedPostDelayMin() const;
|
[[nodiscard]] int suggestedPostDelayMin() const;
|
||||||
[[nodiscard]] int suggestedPostDelayMax() const;
|
[[nodiscard]] int suggestedPostDelayMax() const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue