Provided parent to report toasts.

This commit is contained in:
23rd 2022-04-17 14:47:32 +03:00 committed by John Preston
parent af0a2f182c
commit 2e9e3b3751
4 changed files with 14 additions and 5 deletions

View file

@ -38,6 +38,7 @@ MTPreportReason ReasonToTL(const Ui::ReportReason &reason) {
} // namespace } // namespace
void SendReport( void SendReport(
not_null<QWidget*> toastParent,
not_null<PeerData*> peer, not_null<PeerData*> peer,
Ui::ReportReason reason, Ui::ReportReason reason,
const QString &comment, const QString &comment,
@ -48,7 +49,7 @@ void SendReport(
ReasonToTL(reason), ReasonToTL(reason),
MTP_string(comment) MTP_string(comment)
)).done([=] { )).done([=] {
Ui::Toast::Show(tr::lng_report_thanks(tr::now)); Ui::Toast::Show(toastParent, tr::lng_report_thanks(tr::now));
}).send(); }).send();
} else { } else {
auto apiIds = QVector<MTPint>(); auto apiIds = QVector<MTPint>();
@ -62,7 +63,7 @@ void SendReport(
ReasonToTL(reason), ReasonToTL(reason),
MTP_string(comment) MTP_string(comment)
)).done([=] { )).done([=] {
Ui::Toast::Show(tr::lng_report_thanks(tr::now)); Ui::Toast::Show(toastParent, tr::lng_report_thanks(tr::now));
}).send(); }).send();
} }
} }

View file

@ -16,6 +16,7 @@ enum class ReportReason;
namespace Api { namespace Api {
void SendReport( void SendReport(
not_null<QWidget*> toastParent,
not_null<PeerData*> peer, not_null<PeerData*> peer,
Ui::ReportReason reason, Ui::ReportReason reason,
const QString &comment, const QString &comment,

View file

@ -24,7 +24,8 @@ object_ptr<Ui::BoxContent> ReportItemsBox(
Ui::BoxShow(box).showBox(Box([=](not_null<Ui::GenericBox*> box) { Ui::BoxShow(box).showBox(Box([=](not_null<Ui::GenericBox*> box) {
const auto show = Ui::BoxShow(box); const auto show = Ui::BoxShow(box);
Ui::ReportDetailsBox(box, [=](const QString &text) { 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(); show.hideLayer();
}); });
})); }));
@ -44,7 +45,12 @@ void ShowReportPeerBox(
const auto chosen = [=](Ui::ReportReason reason) { const auto chosen = [=](Ui::ReportReason reason) {
const auto send = [=](const QString &text) { const auto send = [=](const QString &text) {
window->clearChooseReportMessages(); 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()) { if (const auto strong = state->reasonBox.data()) {
strong->closeBox(); strong->closeBox();
} }

View file

@ -3885,7 +3885,8 @@ void HistoryWidget::reportSelectedMessages() {
clearSelected(); clearSelected();
controller()->clearChooseReportMessages(); controller()->clearChooseReportMessages();
} }
Api::SendReport(peer, reason, text, ids); const auto toastParent = Window::Show(controller()).toastParent();
Api::SendReport(toastParent, peer, reason, text, ids);
box->closeBox(); box->closeBox();
}); });
})); }));