From 6afd4dcdd1a7fdccd40f8c7fa33132067aa04347 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 9 Jul 2025 09:31:59 +0400 Subject: [PATCH] Fix stats values display. --- .../statistics/widgets/point_details_widget.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/statistics/widgets/point_details_widget.cpp b/Telegram/SourceFiles/statistics/widgets/point_details_widget.cpp index 97704994aa..c000d919b9 100644 --- a/Telegram/SourceFiles/statistics/widgets/point_details_widget.cpp +++ b/Telegram/SourceFiles/statistics/widgets/point_details_widget.cpp @@ -324,9 +324,8 @@ void PointDetailsWidget::setXIndex(int xIndex) { nullptr, { float64(xIndex), float64(xIndex) }).parts : std::vector(); - const auto multiplier = float64(kOneStarInNano); const auto isCredits - = _chartData.currency == Data::StatisticalCurrency::Credits; + = (_chartData.currency == Data::StatisticalCurrency::Credits); for (auto i = 0; i < _chartData.lines.size(); i++) { const auto &dataLine = _chartData.lines[i]; auto textLine = Line(); @@ -350,19 +349,23 @@ void PointDetailsWidget::setXIndex(int xIndex) { ? tr::lng_channel_earn_chart_overriden_detail_credits : tr::lng_channel_earn_chart_overriden_detail_currency)( tr::now)); + const auto provided = dataLine.y[xIndex]; + const auto value = isCredits + ? CreditsAmount(provided, CreditsType::Stars) + : CreditsAmount( + provided / kOneStarInNano, + provided % kOneStarInNano, + CreditsType::Ton); copy.value.setText( _textStyle, - Lang::FormatExactCountDecimal( - dataLine.y[xIndex] / multiplier)); + Lang::FormatCreditsAmountDecimal(value)); _lines.push_back(std::move(copy)); textLine.name.setText( _textStyle, tr::lng_channel_earn_chart_overriden_detail_usd(tr::now)); textLine.value.setText( _textStyle, - Info::ChannelEarn::ToUsd( - dataLine.y[xIndex] / multiplier, - _chartData.currencyRate, 0)); + Info::ChannelEarn::ToUsd(value, _chartData.currencyRate, 0)); } _lines.push_back(std::move(textLine)); }