From 363ffc1c04c5be9e995897e80703b2823c2d24bf Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 4 Nov 2024 14:05:37 +0400 Subject: [PATCH] Remove unused null option in SendReport(). --- Telegram/SourceFiles/api/api_report.cpp | 27 +++++++------------ Telegram/SourceFiles/api/api_report.h | 4 +-- .../SourceFiles/boxes/report_messages_box.cpp | 19 +++++-------- 3 files changed, 17 insertions(+), 33 deletions(-) diff --git a/Telegram/SourceFiles/api/api_report.cpp b/Telegram/SourceFiles/api/api_report.cpp index 309e2d240..f3b0658bd 100644 --- a/Telegram/SourceFiles/api/api_report.cpp +++ b/Telegram/SourceFiles/api/api_report.cpp @@ -40,29 +40,20 @@ MTPreportReason ReasonToTL(const Ui::ReportReason &reason) { } // namespace -void SendReport( +void SendPhotoReport( std::shared_ptr show, not_null peer, Ui::ReportReason reason, const QString &comment, - std::variant> data) { - auto done = [=] { + not_null photo) { + peer->session().api().request(MTPaccount_ReportProfilePhoto( + peer->input, + photo->mtpInput(), + ReasonToTL(reason), + MTP_string(comment) + )).done([=] { show->showToast(tr::lng_report_thanks(tr::now)); - }; - v::match(data, [&](v::null_t) { - peer->session().api().request(MTPaccount_ReportPeer( - peer->input, - ReasonToTL(reason), - MTP_string(comment) - )).done(std::move(done)).send(); - }, [&](not_null photo) { - peer->session().api().request(MTPaccount_ReportProfilePhoto( - peer->input, - photo->mtpInput(), - ReasonToTL(reason), - MTP_string(comment) - )).done(std::move(done)).send(); - }); + }).send(); } auto CreateReportMessagesOrStoriesCallback( diff --git a/Telegram/SourceFiles/api/api_report.h b/Telegram/SourceFiles/api/api_report.h index f0c0320f3..02d1c9bef 100644 --- a/Telegram/SourceFiles/api/api_report.h +++ b/Telegram/SourceFiles/api/api_report.h @@ -41,12 +41,12 @@ struct ReportResult final { bool successful = false; }; -void SendReport( +void SendPhotoReport( std::shared_ptr show, not_null peer, Ui::ReportReason reason, const QString &comment, - std::variant> data); + not_null photo); [[nodiscard]] auto CreateReportMessagesOrStoriesCallback( std::shared_ptr show, diff --git a/Telegram/SourceFiles/boxes/report_messages_box.cpp b/Telegram/SourceFiles/boxes/report_messages_box.cpp index bac19fbf4..e09825926 100644 --- a/Telegram/SourceFiles/boxes/report_messages_box.cpp +++ b/Telegram/SourceFiles/boxes/report_messages_box.cpp @@ -27,13 +27,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace { -[[nodiscard]] object_ptr Report( +[[nodiscard]] object_ptr ReportPhoto( not_null peer, - std::variant> data, + not_null photo, const style::ReportBox *stOverride) { - const auto source = v::match(data, [](const MessageIdsList &ids) { - return Ui::ReportSource::Message; - }, [&](not_null photo) { + const auto source = [&] { return peer->isUser() ? (photo->hasVideo() ? Ui::ReportSource::ProfileVideo @@ -45,19 +43,14 @@ namespace { : (photo->hasVideo() ? Ui::ReportSource::ChannelVideo : Ui::ReportSource::ChannelPhoto); - }, [&](StoryId id) { - return Ui::ReportSource::Story; - }, [](v::null_t) { - Unexpected("Bad source report."); - return Ui::ReportSource::Bot; - }); + }(); const auto st = stOverride ? stOverride : &st::defaultReportBox; return Box([=](not_null box) { const auto show = box->uiShow(); Ui::ReportReasonBox(box, *st, source, [=](Ui::ReportReason reason) { show->showBox(Box([=](not_null box) { Ui::ReportDetailsBox(box, *st, [=](const QString &text) { - Api::SendReport(show, peer, reason, text, data); + Api::SendPhotoReport(show, peer, reason, text, photo); show->hideLayer(); }); })); @@ -70,7 +63,7 @@ namespace { object_ptr ReportProfilePhotoBox( not_null peer, not_null photo) { - return Report(peer, photo, nullptr); + return ReportPhoto(peer, photo, nullptr); } void ShowReportMessageBox(