diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index a614229983..eaffa62512 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -4967,7 +4967,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_channel_earn_history_title" = "Transaction history"; "lng_channel_earn_history_in" = "Proceeds from ads"; "lng_channel_earn_history_in_about" = "Proceeds from ads displayed in"; -"lng_channel_earn_history_out" = "Balance withdrawal to"; +"lng_channel_earn_history_out" = "Withdrawal"; +"lng_channel_earn_history_out_failed" = "Not Completed"; +"lng_channel_earn_history_out_about_failed" = "Withdrawal failed"; +"lng_channel_earn_history_return" = "Refund"; +"lng_channel_earn_history_return_about" = "Refunded back"; +"lng_channel_earn_history_pending" = "Pending"; "lng_channel_earn_off" = "Switch Off Ads"; "lng_channel_earn_off_about" = "You will not be eligible for any rewards if you switch off ads."; "lng_channel_earn_cpm_min" = "No Ads"; diff --git a/Telegram/SourceFiles/api/api_statistics.cpp b/Telegram/SourceFiles/api/api_statistics.cpp index 78028313bd..4418aa3d5b 100644 --- a/Telegram/SourceFiles/api/api_statistics.cpp +++ b/Telegram/SourceFiles/api/api_statistics.cpp @@ -819,9 +819,13 @@ void EarnStatistics::requestBoosts( : d.is_failed() ? Data::EarnHistoryEntry::Status::Failed : Data::EarnHistoryEntry::Status::Success, - .amount = d.vamount().v, + .amount = d.is_failed() + ? (std::numeric_limits::max() + - d.vamount().v + + 1) + : d.vamount().v, .date = base::unixtime::parse(d.vdate().v), - .provider = qs(d.vprovider()), + // .provider = qs(d.vprovider()), .successDate = d.vtransaction_date() ? base::unixtime::parse(d.vtransaction_date()->v) : QDateTime(), @@ -834,7 +838,7 @@ void EarnStatistics::requestBoosts( .type = Data::EarnHistoryEntry::Type::Return, .amount = d.vamount().v, .date = base::unixtime::parse(d.vdate().v), - .provider = qs(d.vprovider()), + // .provider = qs(d.vprovider()), }; })); } diff --git a/Telegram/SourceFiles/data/data_statistics.h b/Telegram/SourceFiles/data/data_statistics.h index 5e438d88d5..2599cfc495 100644 --- a/Telegram/SourceFiles/data/data_statistics.h +++ b/Telegram/SourceFiles/data/data_statistics.h @@ -155,6 +155,8 @@ struct PublicForwardsSlice final { OffsetToken token; }; +using EarnInt = uint64; + struct EarnHistoryEntry final { enum class Type { In, @@ -171,7 +173,7 @@ struct EarnHistoryEntry final { Type type; Status status; - uint64 amount = 0; + EarnInt amount = 0; QDateTime date; QDateTime dateTo; @@ -196,9 +198,9 @@ struct EarnStatistics final { } Data::StatisticalGraph topHoursGraph; Data::StatisticalGraph revenueGraph; - uint64 currentBalance = 0; - uint64 availableBalance = 0; - uint64 overallRevenue = 0; + EarnInt currentBalance = 0; + EarnInt availableBalance = 0; + EarnInt overallRevenue = 0; float64 usdRate = 0.; EarnHistorySlice firstHistorySlice; diff --git a/Telegram/SourceFiles/info/channel_statistics/earn/channel_earn.style b/Telegram/SourceFiles/info/channel_statistics/earn/channel_earn.style index 653f3c87ba..c3007e16d0 100644 --- a/Telegram/SourceFiles/info/channel_statistics/earn/channel_earn.style +++ b/Telegram/SourceFiles/info/channel_statistics/earn/channel_earn.style @@ -48,7 +48,7 @@ channelEarnHistoryRecipientLabel: FlatLabel(channelEarnOverviewSubMinorLabel) { } channelEarnHistoryMajorLabel: FlatLabel(channelEarnOverviewMajorLabel) { style: TextStyle(defaultTextStyle) { - font: font(13px semibold); + font: font(14px semibold); } } channelEarnHistoryMinorLabel: FlatLabel(channelEarnOverviewMinorLabel) { @@ -56,7 +56,7 @@ channelEarnHistoryMinorLabel: FlatLabel(channelEarnOverviewMinorLabel) { font: font(12px semibold); } } -channelEarnHistoryMinorLabelSkip: 1px; +channelEarnHistoryMinorLabelSkip: 2px; channelEarnHistoryOuter: margins(0px, 6px, 0px, 6px); channelEarnHistoryTwoSkip: 5px; channelEarnHistoryThreeSkip: 3px; diff --git a/Telegram/SourceFiles/info/channel_statistics/earn/info_earn_inner_widget.cpp b/Telegram/SourceFiles/info/channel_statistics/earn/info_earn_inner_widget.cpp index ffbac06193..0a7714baf6 100644 --- a/Telegram/SourceFiles/info/channel_statistics/earn/info_earn_inner_widget.cpp +++ b/Telegram/SourceFiles/info/channel_statistics/earn/info_earn_inner_widget.cpp @@ -46,18 +46,20 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Info::ChannelEarn { namespace { +using EarnInt = Data::EarnInt; + constexpr auto kMinorPartLength = 9; constexpr auto kZero = QChar('0'); constexpr auto kDot = QChar('.'); -[[nodiscard]] QString MajorPart(uint64 value) { +[[nodiscard]] QString MajorPart(EarnInt value) { const auto string = QString::number(value); return (string.size() < kMinorPartLength) ? QString(kZero) : string.mid(0, kMinorPartLength); } -[[nodiscard]] QString MinorPart(uint64 value) { +[[nodiscard]] QString MinorPart(EarnInt value) { if (!value) { return QString(kDot) + kZero; } @@ -81,10 +83,10 @@ constexpr auto kDot = QChar('.'); return result.chopped(zeroCount); } -[[nodiscard]] QString ToUsd(uint64 value, float64 rate) { +[[nodiscard]] QString ToUsd(EarnInt value, float64 rate) { constexpr auto kApproximately = QChar(0x2248); - constexpr auto kMultiplier = uint64(1000000000); - const auto multiplier = uint64(rate * kMultiplier); + constexpr auto kMultiplier = EarnInt(1000000000); + const auto multiplier = EarnInt(rate * kMultiplier); const auto result = (value * multiplier) / kMultiplier; return QString(kApproximately) + QChar('$') @@ -214,7 +216,7 @@ void InnerWidget::fill() { }; const auto addEmojiToMajor = [=]( not_null label, - uint64 value) { + EarnInt value) { auto emoji = EmojiCurrency(session); label->setMarkedText( emoji.append(' ').append(MajorPart(value)), @@ -402,7 +404,7 @@ void InnerWidget::fill() { Ui::AddSkip(container, st::channelEarnOverviewTitleSkip); const auto addOverview = [&]( - uint64 value, + EarnInt value, const tr::phrase<> &text) { const auto line = container->add( Ui::CreateSkipWidget(container, 0), @@ -506,20 +508,6 @@ void InnerWidget::fill() { Ui::AddSkip(container); - const auto input = container->add( - object_ptr( - container, - st::defaultComposeFiles.caption, - Ui::InputField::Mode::MultiLine, - tr::lng_channel_earn_balance_placeholder()), - st::boxRowPadding); - _focusRequested.events( - ) | rpl::start_with_next([=] { - input->setFocusFast(); - }, input->lifetime()); - - Ui::AddSkip(container); - const auto &stButton = st::defaultActiveButton; const auto button = container->add( object_ptr( @@ -552,49 +540,9 @@ void InnerWidget::fill() { stButton.textFg->c, anim::interpolateF(.5, 1., value))); }; - colorText(0); - - rpl::single( - rpl::empty_value() - ) | rpl::then( - input->changes() - ) | rpl::map([=, end = (u".ton"_q)] { - const auto text = input->getLastText(); - return (text.size() == 48) - || text.endsWith(end, Qt::CaseInsensitive); - }) | rpl::distinct_until_changed( - ) | rpl::start_with_next([=](bool enabled) { - fadeAnimation->stop(); - const auto from = enabled ? 0. : 1.; - const auto to = enabled ? 1. : 0.; - fadeAnimation->start(colorText, from, to, st::slideWrapDuration); - - button->setAttribute(Qt::WA_TransparentForMouseEvents, !enabled); - }, button->lifetime()); + colorText(1.); button->setClickedCallback([=] { - _show->showBox(Box([=](not_null box) { - box->setTitle(tr::lng_channel_earn_balance_button()); - box->addRow(object_ptr( - box, - tr::lng_channel_earn_transfer_sure_about1(tr::now), - st::boxLabel)); - Ui::AddSkip(box->verticalLayout()); - AddRecipient( - box, - Ui::Text::Wrapped( - { input->getLastText() }, - EntityType::Code)); - Ui::AddSkip(box->verticalLayout()); - box->addRow(object_ptr( - box, - tr::lng_channel_earn_transfer_sure_about2(tr::now), - st::boxLabel)); - box->addButton( - tr::lng_send_button(), - [=] { box->closeBox(); }); - box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); - })); }); Ui::ToggleChildrenVisibility(button, true); @@ -642,17 +590,28 @@ void InnerWidget::fill() { Ui::AddSkip(inner, st::channelEarnHistoryTwoSkip); } - const auto dateText = !entry.dateTo.isNull() + const auto isFailed = entry.status + == Data::EarnHistoryEntry::Status::Failed; + const auto isPending = entry.status + == Data::EarnHistoryEntry::Status::Pending; + const auto dateText = (!entry.dateTo.isNull() || isFailed) ? (FormatDate(entry.date) + ' ' + QChar(8212) + ' ' - + FormatDate(entry.dateTo)) + + (isFailed + ? tr::lng_channel_earn_history_out_failed(tr::now) + : FormatDate(entry.dateTo))) + : isPending + ? tr::lng_channel_earn_history_pending(tr::now) : FormatDate(entry.date); inner->add(object_ptr( inner, dateText, - st::channelEarnHistorySubLabel)); + st::channelEarnHistorySubLabel) + )->setTextColorOverride(isFailed + ? std::make_optional(st::menuIconAttentionColor->c) + : std::nullopt); const auto color = (isIn ? st::boxTextFgGood @@ -826,6 +785,8 @@ void InnerWidget::fill() { entry, (entry.type == Data::EarnHistoryEntry::Type::In) ? tr::lng_channel_earn_history_in + : (entry.type == Data::EarnHistoryEntry::Type::Return) + ? tr::lng_channel_earn_history_return : tr::lng_channel_earn_history_out); } }