diff --git a/Telegram/SourceFiles/data/data_sponsored_messages.cpp b/Telegram/SourceFiles/data/data_sponsored_messages.cpp index ae37e9191..a856e6156 100644 --- a/Telegram/SourceFiles/data/data_sponsored_messages.cpp +++ b/Telegram/SourceFiles/data/data_sponsored_messages.cpp @@ -546,6 +546,9 @@ auto SponsoredMessages::createReportCallback(const FullMsgId &fullId) }; list.erase(ranges::remove_if(list, proj), end(list)); } + if (optionId == Result::Id("1")) { // I don't like it. + return { .result = Result::FinalStep::Silence }; + } return { .result = Result::FinalStep::Reported }; })); }).fail([=](const MTP::Error &error) { diff --git a/Telegram/SourceFiles/data/data_sponsored_messages.h b/Telegram/SourceFiles/data/data_sponsored_messages.h index 04f0cd196..cad8a6134 100644 --- a/Telegram/SourceFiles/data/data_sponsored_messages.h +++ b/Telegram/SourceFiles/data/data_sponsored_messages.h @@ -33,6 +33,7 @@ struct SponsoredReportResult final { Hidden, Reported, Premium, + Silence, }; Options options; QString title; diff --git a/Telegram/SourceFiles/info/channel_statistics/earn/channel_earn.style b/Telegram/SourceFiles/info/channel_statistics/earn/channel_earn.style index 0667ce763..4c7acfe31 100644 --- a/Telegram/SourceFiles/info/channel_statistics/earn/channel_earn.style +++ b/Telegram/SourceFiles/info/channel_statistics/earn/channel_earn.style @@ -117,3 +117,8 @@ sponsoredAboutSplitIcon: icon {{ "sponsored/revenue_split", boxTextFg }}; channelEarnLearnTitleIcon: icon {{ "sponsored/large_earn", activeButtonFg }}; channelEarnLearnChannelIcon: icon {{ "sponsored/channel", boxTextFg }}; channelEarnLearnWithdrawalsIcon: icon {{ "sponsored/withdrawals", boxTextFg }}; + +sponsoredReportLabel: FlatLabel(defaultFlatLabel) { + style: boxTextStyle; + minWidth: 150px; +} diff --git a/Telegram/SourceFiles/menu/menu_sponsored.cpp b/Telegram/SourceFiles/menu/menu_sponsored.cpp index 51aaad13e..3d7105fe9 100644 --- a/Telegram/SourceFiles/menu/menu_sponsored.cpp +++ b/Telegram/SourceFiles/menu/menu_sponsored.cpp @@ -238,8 +238,42 @@ void ShowReportSponsoredBox( const auto button = box->verticalLayout()->add( object_ptr( box, - rpl::single(option.text), + rpl::single(QString()), st::settingsButtonNoIcon)); + const auto label = Ui::CreateChild( + button, + rpl::single(option.text), + st::sponsoredReportLabel); + const auto icon = Ui::CreateChild( + button); + icon->resize(st::settingsPremiumArrow.size()); + icon->paintRequest( + ) | rpl::start_with_next([=, w = icon->width()] { + auto p = Painter(icon); + st::settingsPremiumArrow.paint(p, 0, 0, w); + }, icon->lifetime()); + button->sizeValue( + ) | rpl::start_with_next([=](const QSize &size) { + const auto left = button->st().padding.left(); + const auto right = button->st().padding.right(); + icon->moveToRight( + right, + (size.height() - icon->height()) / 2); + label->resizeToWidth(size.width() + - icon->width() + - left + - st::settingsButtonRightSkip + - right); + label->moveToLeft( + left, + (size.height() - label->height()) / 2); + button->resize( + button->width(), + rect::m::sum::v(button->st().padding) + + label->height()); + }, button->lifetime()); + label->setAttribute(Qt::WA_TransparentForMouseEvents); + icon->setAttribute(Qt::WA_TransparentForMouseEvents); button->setClickedCallback([=] { repeatRequest(repeatRequest, option.id); }); @@ -268,9 +302,12 @@ void ShowReportSponsoredBox( [=] { show->hideLayer(); }); })); } else { + constexpr auto kToastDuration = crl::time(4000); switch (result.result) { case Data::SponsoredReportResult::FinalStep::Hidden: { - show->showToast(tr::lng_report_sponsored_hidden(tr::now)); + show->showToast( + tr::lng_report_sponsored_hidden(tr::now), + kToastDuration); } break; case Data::SponsoredReportResult::FinalStep::Reported: { auto text = tr::lng_report_sponsored_reported( @@ -278,7 +315,10 @@ void ShowReportSponsoredBox( lt_link, guideLink, Ui::Text::WithEntities); - show->showToast({ .text = std::move(text) }); + show->showToast({ + .text = std::move(text), + .duration = kToastDuration, + }); } break; case Data::SponsoredReportResult::FinalStep::Premium: { ShowPremiumPreviewBox(show, PremiumFeature::NoAds);