From 2e9e3b375187d15ca5e7c27e64d83ddeb9aa813a Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 17 Apr 2022 14:47:32 +0300 Subject: [PATCH] Provided parent to report toasts. --- Telegram/SourceFiles/api/api_report.cpp | 5 +++-- Telegram/SourceFiles/api/api_report.h | 1 + Telegram/SourceFiles/boxes/report_messages_box.cpp | 10 ++++++++-- Telegram/SourceFiles/history/history_widget.cpp | 3 ++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/api/api_report.cpp b/Telegram/SourceFiles/api/api_report.cpp index 9238db1fa5..29c5a7118d 100644 --- a/Telegram/SourceFiles/api/api_report.cpp +++ b/Telegram/SourceFiles/api/api_report.cpp @@ -38,6 +38,7 @@ MTPreportReason ReasonToTL(const Ui::ReportReason &reason) { } // namespace void SendReport( + not_null toastParent, not_null peer, Ui::ReportReason reason, const QString &comment, @@ -48,7 +49,7 @@ void SendReport( ReasonToTL(reason), MTP_string(comment) )).done([=] { - Ui::Toast::Show(tr::lng_report_thanks(tr::now)); + Ui::Toast::Show(toastParent, tr::lng_report_thanks(tr::now)); }).send(); } else { auto apiIds = QVector(); @@ -62,7 +63,7 @@ void SendReport( ReasonToTL(reason), MTP_string(comment) )).done([=] { - Ui::Toast::Show(tr::lng_report_thanks(tr::now)); + Ui::Toast::Show(toastParent, tr::lng_report_thanks(tr::now)); }).send(); } } diff --git a/Telegram/SourceFiles/api/api_report.h b/Telegram/SourceFiles/api/api_report.h index cfe7d80b7a..c134e0db06 100644 --- a/Telegram/SourceFiles/api/api_report.h +++ b/Telegram/SourceFiles/api/api_report.h @@ -16,6 +16,7 @@ enum class ReportReason; namespace Api { void SendReport( + not_null toastParent, not_null peer, Ui::ReportReason reason, const QString &comment, diff --git a/Telegram/SourceFiles/boxes/report_messages_box.cpp b/Telegram/SourceFiles/boxes/report_messages_box.cpp index 3fb3139eb8..9d5e3ab0d0 100644 --- a/Telegram/SourceFiles/boxes/report_messages_box.cpp +++ b/Telegram/SourceFiles/boxes/report_messages_box.cpp @@ -24,7 +24,8 @@ object_ptr ReportItemsBox( Ui::BoxShow(box).showBox(Box([=](not_null box) { const auto show = Ui::BoxShow(box); Ui::ReportDetailsBox(box, [=](const QString &text) { - Api::SendReport(peer, reason, text, ids); + const auto toastParent = show.toastParent(); + Api::SendReport(toastParent, peer, reason, text, ids); show.hideLayer(); }); })); @@ -44,7 +45,12 @@ void ShowReportPeerBox( const auto chosen = [=](Ui::ReportReason reason) { const auto send = [=](const QString &text) { window->clearChooseReportMessages(); - Api::SendReport(peer, reason, text, std::move(state->ids)); + Api::SendReport( + Window::Show(window).toastParent(), + peer, + reason, + text, + std::move(state->ids)); if (const auto strong = state->reasonBox.data()) { strong->closeBox(); } diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 2625691d86..19d3709b7f 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -3885,7 +3885,8 @@ void HistoryWidget::reportSelectedMessages() { clearSelected(); controller()->clearChooseReportMessages(); } - Api::SendReport(peer, reason, text, ids); + const auto toastParent = Window::Show(controller()).toastParent(); + Api::SendReport(toastParent, peer, reason, text, ids); box->closeBox(); }); }));