mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 07:37:11 +02:00
Removed Ui::show from ShowReportItemsBox.
This commit is contained in:
parent
e3ac84a849
commit
af0a2f182c
4 changed files with 33 additions and 29 deletions
|
@ -8,34 +8,36 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/report_messages_box.h"
|
||||
|
||||
#include "api/api_report.h"
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "facades.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/boxes/report_box.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "window/window_session_controller.h"
|
||||
|
||||
void ShowReportItemsBox(not_null<PeerData*> peer, MessageIdsList ids) {
|
||||
const auto chosen = [=](Ui::ReportReason reason) {
|
||||
Ui::show(Box(Ui::ReportDetailsBox, [=](const QString &text) {
|
||||
Api::SendReport(peer, reason, text, ids);
|
||||
Ui::hideLayer();
|
||||
}));
|
||||
};
|
||||
Ui::show(Box(
|
||||
Ui::ReportReasonBox,
|
||||
Ui::ReportSource::Message,
|
||||
chosen));
|
||||
object_ptr<Ui::BoxContent> ReportItemsBox(
|
||||
not_null<PeerData*> peer,
|
||||
MessageIdsList ids) {
|
||||
return Box([=](not_null<Ui::GenericBox*> box) {
|
||||
using Source = Ui::ReportSource;
|
||||
using Reason = Ui::ReportReason;
|
||||
Ui::ReportReasonBox(box, Source::Message, [=](Reason reason) {
|
||||
Ui::BoxShow(box).showBox(Box([=](not_null<Ui::GenericBox*> box) {
|
||||
const auto show = Ui::BoxShow(box);
|
||||
Ui::ReportDetailsBox(box, [=](const QString &text) {
|
||||
Api::SendReport(peer, reason, text, ids);
|
||||
show.hideLayer();
|
||||
});
|
||||
}));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void ShowReportPeerBox(
|
||||
not_null<Window::SessionController*> window,
|
||||
not_null<PeerData*> peer) {
|
||||
struct State {
|
||||
QPointer<Ui::GenericBox> reasonBox;
|
||||
QPointer<Ui::GenericBox> detailsBox;
|
||||
QPointer<Ui::BoxContent> reasonBox;
|
||||
QPointer<Ui::BoxContent> detailsBox;
|
||||
MessageIdsList ids;
|
||||
};
|
||||
const auto state = std::make_shared<State>();
|
||||
|
@ -53,18 +55,16 @@ void ShowReportPeerBox(
|
|||
if (reason == Ui::ReportReason::Fake
|
||||
|| reason == Ui::ReportReason::Other) {
|
||||
state->ids = {};
|
||||
state->detailsBox = window->window().show(
|
||||
Box(Ui::ReportDetailsBox, send));
|
||||
state->detailsBox = window->show(Box(Ui::ReportDetailsBox, send));
|
||||
return;
|
||||
}
|
||||
window->showChooseReportMessages(peer, reason, [=](
|
||||
MessageIdsList ids) {
|
||||
state->ids = std::move(ids);
|
||||
state->detailsBox = window->window().show(
|
||||
Box(Ui::ReportDetailsBox, send));
|
||||
state->detailsBox = window->show(Box(Ui::ReportDetailsBox, send));
|
||||
});
|
||||
};
|
||||
state->reasonBox = window->window().show(Box(
|
||||
state->reasonBox = window->show(Box(
|
||||
Ui::ReportReasonBox,
|
||||
(peer->isBroadcast()
|
||||
? Ui::ReportSource::Channel
|
||||
|
|
|
@ -7,8 +7,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
template <typename Object>
|
||||
class object_ptr;
|
||||
|
||||
namespace Ui {
|
||||
class GenericBox;
|
||||
class BoxContent;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window {
|
||||
|
@ -17,8 +20,9 @@ class SessionController;
|
|||
|
||||
class PeerData;
|
||||
|
||||
void ShowReportItemsBox(
|
||||
not_null<PeerData*> peer, MessageIdsList ids);
|
||||
[[nodiscard]] object_ptr<Ui::BoxContent> ReportItemsBox(
|
||||
not_null<PeerData*> peer,
|
||||
MessageIdsList ids);
|
||||
void ShowReportPeerBox(
|
||||
not_null<Window::SessionController*> window,
|
||||
not_null<PeerData*> peer);
|
||||
|
|
|
@ -3865,17 +3865,17 @@ void HistoryInner::deleteAsGroup(FullMsgId itemId) {
|
|||
}
|
||||
|
||||
void HistoryInner::reportItem(FullMsgId itemId) {
|
||||
ShowReportItemsBox(_peer, { 1, itemId });
|
||||
_controller->show(ReportItemsBox(_peer, { 1, itemId }));
|
||||
}
|
||||
|
||||
void HistoryInner::reportAsGroup(FullMsgId itemId) {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
const auto group = session().data().groups().find(item);
|
||||
ShowReportItemsBox(
|
||||
_controller->show(ReportItemsBox(
|
||||
_peer,
|
||||
(group
|
||||
? session().data().itemsToIds(group->items)
|
||||
: MessageIdsList{ 1, itemId }));
|
||||
: MessageIdsList{ 1, itemId })));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -808,11 +808,11 @@ void AddReportAction(
|
|||
const auto callback = crl::guard(controller, [=] {
|
||||
if (const auto item = owner->message(itemId)) {
|
||||
const auto group = owner->groups().find(item);
|
||||
ShowReportItemsBox(
|
||||
controller->show(ReportItemsBox(
|
||||
item->history()->peer,
|
||||
(group
|
||||
? owner->itemsToIds(group->items)
|
||||
: MessageIdsList{ 1, itemId }));
|
||||
: MessageIdsList{ 1, itemId })));
|
||||
}
|
||||
});
|
||||
menu->addAction(
|
||||
|
|
Loading…
Add table
Reference in a new issue