Remove unused null option in SendReport().

This commit is contained in:
John Preston 2024-11-04 14:05:37 +04:00
parent 4001899bdf
commit 363ffc1c04
3 changed files with 17 additions and 33 deletions

View file

@ -40,29 +40,20 @@ MTPreportReason ReasonToTL(const Ui::ReportReason &reason) {
} // namespace
void SendReport(
void SendPhotoReport(
std::shared_ptr<Ui::Show> show,
not_null<PeerData*> peer,
Ui::ReportReason reason,
const QString &comment,
std::variant<v::null_t, not_null<PhotoData*>> data) {
auto done = [=] {
not_null<PhotoData*> 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<PhotoData*> photo) {
peer->session().api().request(MTPaccount_ReportProfilePhoto(
peer->input,
photo->mtpInput(),
ReasonToTL(reason),
MTP_string(comment)
)).done(std::move(done)).send();
});
}).send();
}
auto CreateReportMessagesOrStoriesCallback(

View file

@ -41,12 +41,12 @@ struct ReportResult final {
bool successful = false;
};
void SendReport(
void SendPhotoReport(
std::shared_ptr<Ui::Show> show,
not_null<PeerData*> peer,
Ui::ReportReason reason,
const QString &comment,
std::variant<v::null_t, not_null<PhotoData*>> data);
not_null<PhotoData*> photo);
[[nodiscard]] auto CreateReportMessagesOrStoriesCallback(
std::shared_ptr<Ui::Show> show,

View file

@ -27,13 +27,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace {
[[nodiscard]] object_ptr<Ui::BoxContent> Report(
[[nodiscard]] object_ptr<Ui::BoxContent> ReportPhoto(
not_null<PeerData*> peer,
std::variant<v::null_t, not_null<PhotoData*>> data,
not_null<PhotoData*> photo,
const style::ReportBox *stOverride) {
const auto source = v::match(data, [](const MessageIdsList &ids) {
return Ui::ReportSource::Message;
}, [&](not_null<PhotoData*> 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<Ui::GenericBox*> box) {
const auto show = box->uiShow();
Ui::ReportReasonBox(box, *st, source, [=](Ui::ReportReason reason) {
show->showBox(Box([=](not_null<Ui::GenericBox*> 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<Ui::BoxContent> ReportProfilePhotoBox(
not_null<PeerData*> peer,
not_null<PhotoData*> photo) {
return Report(peer, photo, nullptr);
return ReportPhoto(peer, photo, nullptr);
}
void ShowReportMessageBox(