mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 23:27:09 +02:00
Moved boxes for reporting messages or peers to separated file.
This commit is contained in:
parent
6dce8dfa20
commit
e3ac84a849
8 changed files with 109 additions and 66 deletions
|
@ -260,6 +260,8 @@ PRIVATE
|
|||
boxes/pin_messages_box.h
|
||||
boxes/reactions_settings_box.cpp
|
||||
boxes/reactions_settings_box.h
|
||||
boxes/report_messages_box.cpp
|
||||
boxes/report_messages_box.h
|
||||
boxes/ringtones_box.cpp
|
||||
boxes/ringtones_box.h
|
||||
boxes/self_destruction_box.cpp
|
||||
|
|
75
Telegram/SourceFiles/boxes/report_messages_box.cpp
Normal file
75
Telegram/SourceFiles/boxes/report_messages_box.cpp
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
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));
|
||||
}
|
||||
|
||||
void ShowReportPeerBox(
|
||||
not_null<Window::SessionController*> window,
|
||||
not_null<PeerData*> peer) {
|
||||
struct State {
|
||||
QPointer<Ui::GenericBox> reasonBox;
|
||||
QPointer<Ui::GenericBox> detailsBox;
|
||||
MessageIdsList ids;
|
||||
};
|
||||
const auto state = std::make_shared<State>();
|
||||
const auto chosen = [=](Ui::ReportReason reason) {
|
||||
const auto send = [=](const QString &text) {
|
||||
window->clearChooseReportMessages();
|
||||
Api::SendReport(peer, reason, text, std::move(state->ids));
|
||||
if (const auto strong = state->reasonBox.data()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
if (const auto strong = state->detailsBox.data()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
if (reason == Ui::ReportReason::Fake
|
||||
|| reason == Ui::ReportReason::Other) {
|
||||
state->ids = {};
|
||||
state->detailsBox = window->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->reasonBox = window->window().show(Box(
|
||||
Ui::ReportReasonBox,
|
||||
(peer->isBroadcast()
|
||||
? Ui::ReportSource::Channel
|
||||
: peer->isUser()
|
||||
? Ui::ReportSource::Bot
|
||||
: Ui::ReportSource::Group),
|
||||
chosen));
|
||||
}
|
24
Telegram/SourceFiles/boxes/report_messages_box.h
Normal file
24
Telegram/SourceFiles/boxes/report_messages_box.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace Ui {
|
||||
class GenericBox;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Main
|
||||
|
||||
class PeerData;
|
||||
|
||||
void ShowReportItemsBox(
|
||||
not_null<PeerData*> peer, MessageIdsList ids);
|
||||
void ShowReportPeerBox(
|
||||
not_null<Window::SessionController*> window,
|
||||
not_null<PeerData*> peer);
|
|
@ -47,6 +47,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "window/notifications_manager.h"
|
||||
#include "boxes/about_sponsored_box.h"
|
||||
#include "boxes/delete_messages_box.h"
|
||||
#include "boxes/report_messages_box.h"
|
||||
#include "boxes/sticker_set_box.h"
|
||||
#include "chat_helpers/message_field.h"
|
||||
#include "chat_helpers/emoji_interactions.h"
|
||||
|
@ -3864,13 +3865,13 @@ void HistoryInner::deleteAsGroup(FullMsgId itemId) {
|
|||
}
|
||||
|
||||
void HistoryInner::reportItem(FullMsgId itemId) {
|
||||
HistoryView::ShowReportItemsBox(_peer, { 1, itemId });
|
||||
ShowReportItemsBox(_peer, { 1, itemId });
|
||||
}
|
||||
|
||||
void HistoryInner::reportAsGroup(FullMsgId itemId) {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
const auto group = session().data().groups().find(item);
|
||||
HistoryView::ShowReportItemsBox(
|
||||
ShowReportItemsBox(
|
||||
_peer,
|
||||
(group
|
||||
? session().data().itemsToIds(group->items)
|
||||
|
|
|
@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "menu/menu_send.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "boxes/delete_messages_box.h"
|
||||
#include "boxes/report_messages_box.h"
|
||||
#include "boxes/sticker_set_box.h"
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_photo_media.h"
|
||||
|
@ -1205,61 +1206,4 @@ void ShowWhoReactedMenu(
|
|||
}, lifetime);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
void ShowReportPeerBox(
|
||||
not_null<Window::SessionController*> window,
|
||||
not_null<PeerData*> peer) {
|
||||
struct State {
|
||||
QPointer<Ui::GenericBox> reasonBox;
|
||||
QPointer<Ui::GenericBox> detailsBox;
|
||||
MessageIdsList ids;
|
||||
};
|
||||
const auto state = std::make_shared<State>();
|
||||
const auto chosen = [=](Ui::ReportReason reason) {
|
||||
const auto send = [=](const QString &text) {
|
||||
window->clearChooseReportMessages();
|
||||
Api::SendReport(peer, reason, text, std::move(state->ids));
|
||||
if (const auto strong = state->reasonBox.data()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
if (const auto strong = state->detailsBox.data()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
if (reason == Ui::ReportReason::Fake
|
||||
|| reason == Ui::ReportReason::Other) {
|
||||
state->ids = {};
|
||||
state->detailsBox = window->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->reasonBox = window->window().show(Box(
|
||||
Ui::ReportReasonBox,
|
||||
(peer->isBroadcast()
|
||||
? Ui::ReportSource::Channel
|
||||
: peer->isUser()
|
||||
? Ui::ReportSource::Bot
|
||||
: Ui::ReportSource::Group),
|
||||
chosen));
|
||||
}
|
||||
|
||||
} // namespace HistoryView
|
||||
|
|
|
@ -79,9 +79,4 @@ void ShowWhoReactedMenu(
|
|||
not_null<Window::SessionController*> controller,
|
||||
rpl::lifetime &lifetime);
|
||||
|
||||
void ShowReportItemsBox(not_null<PeerData*> peer, MessageIdsList ids);
|
||||
void ShowReportPeerBox(
|
||||
not_null<Window::SessionController*> window,
|
||||
not_null<PeerData*> peer);
|
||||
|
||||
} // namespace HistoryView
|
||||
|
|
|
@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/add_contact_box.h"
|
||||
#include "boxes/peers/add_bot_to_chat_box.h"
|
||||
#include "boxes/peers/edit_contact_box.h"
|
||||
#include "boxes/report_messages_box.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "menu/menu_mute.h"
|
||||
#include "info/info_controller.h"
|
||||
|
@ -619,7 +620,7 @@ void ActionsFiller::addReportAction() {
|
|||
const auto peer = _peer;
|
||||
const auto controller = _controller->parentController();
|
||||
const auto report = [=] {
|
||||
HistoryView::ShowReportPeerBox(controller, peer);
|
||||
ShowReportPeerBox(controller, peer);
|
||||
};
|
||||
AddActionButton(
|
||||
_wrap,
|
||||
|
|
|
@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/choose_filter_box.h"
|
||||
#include "boxes/create_poll_box.h"
|
||||
#include "boxes/pin_messages_box.h"
|
||||
#include "boxes/report_messages_box.h"
|
||||
#include "boxes/peers/add_bot_to_chat_box.h"
|
||||
#include "boxes/peers/add_participants_box.h"
|
||||
#include "boxes/peers/edit_contact_box.h"
|
||||
|
@ -631,7 +632,7 @@ void Filler::addReport() {
|
|||
const auto peer = _peer;
|
||||
const auto navigation = _controller;
|
||||
_addAction(tr::lng_profile_report(tr::now), [=] {
|
||||
HistoryView::ShowReportPeerBox(navigation, peer);
|
||||
ShowReportPeerBox(navigation, peer);
|
||||
}, &st::menuIconReport);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue