Use better ratio stars/usd/ton.

This commit is contained in:
John Preston
2025-12-05 18:57:52 +04:00
parent 542326af8f
commit 0df3be8630
5 changed files with 27 additions and 19 deletions
@@ -726,15 +726,6 @@ void ShowGiftSaleAcceptBox(
const auto nanoTonThousandths = appConfig.giftResaleNanoTonThousandths();
controller->show(Box([=](not_null<Ui::GenericBox*> box) {
auto button = tr::lng_gift_offer_sell_for(
lt_price,
rpl::single(Ui::Text::IconEmoji(
&st::starIconEmoji
).append(Lang::FormatCreditsAmountDecimal(
price
))),
tr::marked);
struct State {
bool sent = false;
};
@@ -763,6 +754,14 @@ void ShowGiftSaleAcceptBox(
? ((price.value() * nanoTonThousandths) / 1000.)
: ((int64(price.value()) * starsThousandths) / 1000);
auto button = tr::lng_gift_offer_sell_for(
lt_price,
rpl::single(Ui::Text::IconEmoji(price.ton()
? &st::buttonTonIconEmoji
: &st::buttonStarIconEmoji
).append(Lang::FormatExactCountDecimal(receive))),
tr::marked);
box->addRow(
CreateGiftTransfer(box->verticalLayout(), gift, peer),
QMargins(0, st::boxPadding.top(), 0, 0));
@@ -807,8 +806,8 @@ void ShowGiftSaleAcceptBox(
/ std::pow(10., rule.exponent);
if (std::abs(value) >= 0.01) {
const auto rate = price.ton()
? appConfig->currencyWithdrawRate()
: (appConfig->starsWithdrawRate() / 100.);
? appConfig->currencySellRate()
: (appConfig->starsSellRate() / 100.);
const auto offered = receive * rate;
const auto diff = offered - value;
const auto percent = std::abs(diff / value * 100.);
@@ -826,8 +825,7 @@ void ShowGiftSaleAcceptBox(
lt_percent,
rpl::single(tr::bold(percentText)),
lt_name,
rpl::single(tr::marked(
UniqueGiftName(*gift))),
rpl::single(tr::marked(gift->title)),
tr::marked),
(good ? st::offerValueGood : st::offerValueBad)),
st::boxRowPadding + st::offerValuePadding