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