mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Added api support for stories reports with server options.
This commit is contained in:
parent
ede771e51b
commit
e565acba91
10 changed files with 77 additions and 41 deletions
|
@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "window/window_session_controller.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_settings.h"
|
||||
|
||||
namespace {
|
||||
|
@ -76,7 +77,8 @@ void ShowReportMessageBox(
|
|||
std::shared_ptr<Ui::Show> show,
|
||||
not_null<PeerData*> peer,
|
||||
const std::vector<MsgId> &ids,
|
||||
const std::vector<StoryId> &stories) {
|
||||
const std::vector<StoryId> &stories,
|
||||
const style::ReportBox *stOverride) {
|
||||
const auto report = Api::CreateReportMessagesOrStoriesCallback(
|
||||
show,
|
||||
peer);
|
||||
|
@ -120,7 +122,8 @@ void ShowReportMessageBox(
|
|||
for (const auto &option : result.options) {
|
||||
const auto button = Ui::AddReportOptionButton(
|
||||
box->verticalLayout(),
|
||||
option.text);
|
||||
option.text,
|
||||
stOverride);
|
||||
button->setClickedCallback([=] {
|
||||
auto copy = reportInput;
|
||||
copy.optionId = option.id;
|
||||
|
@ -130,14 +133,16 @@ void ShowReportMessageBox(
|
|||
}
|
||||
if (const auto commentOption = result.commentOption) {
|
||||
constexpr auto kReportReasonLengthMax = 512;
|
||||
const auto &st = st::defaultReportBox;
|
||||
const auto &st = stOverride
|
||||
? stOverride
|
||||
: &st::defaultReportBox;
|
||||
Ui::AddReportDetailsIconButton(box);
|
||||
Ui::AddSkip(box->verticalLayout());
|
||||
Ui::AddSkip(box->verticalLayout());
|
||||
const auto details = box->addRow(
|
||||
object_ptr<Ui::InputField>(
|
||||
box,
|
||||
st.field,
|
||||
st->field,
|
||||
Ui::InputField::Mode::MultiLine,
|
||||
commentOption->optional
|
||||
? tr::lng_report_details_optional()
|
||||
|
@ -145,9 +150,31 @@ void ShowReportMessageBox(
|
|||
QString()));
|
||||
Ui::AddSkip(box->verticalLayout());
|
||||
Ui::AddSkip(box->verticalLayout());
|
||||
Ui::AddDividerText(
|
||||
box->verticalLayout(),
|
||||
tr::lng_report_details_message_about());
|
||||
{
|
||||
const auto container = box->verticalLayout();
|
||||
auto label = object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
tr::lng_report_details_message_about(),
|
||||
st::boxDividerLabel);
|
||||
label->setTextColorOverride(st->dividerFg->c);
|
||||
using namespace Ui;
|
||||
const auto widget = container->add(
|
||||
object_ptr<PaddingWrap<>>(
|
||||
container,
|
||||
std::move(label),
|
||||
st::defaultBoxDividerLabelPadding));
|
||||
const auto background
|
||||
= CreateChild<BoxContentDivider>(
|
||||
widget,
|
||||
st::boxDividerHeight,
|
||||
st->dividerBg,
|
||||
RectPart::Top | RectPart::Bottom);
|
||||
background->lower();
|
||||
widget->sizeValue(
|
||||
) | rpl::start_with_next([=](const QSize &s) {
|
||||
background->resize(s);
|
||||
}, background->lifetime());
|
||||
}
|
||||
details->setMaxLength(kReportReasonLengthMax);
|
||||
box->setFocusCallback([=] {
|
||||
details->setFocusFast();
|
||||
|
|
|
@ -15,6 +15,10 @@ class BoxContent;
|
|||
class Show;
|
||||
} // namespace Ui
|
||||
|
||||
namespace style {
|
||||
struct ReportBox;
|
||||
} // namespace style
|
||||
|
||||
class PeerData;
|
||||
|
||||
[[nodiscard]] object_ptr<Ui::BoxContent> ReportProfilePhotoBox(
|
||||
|
@ -25,4 +29,5 @@ void ShowReportMessageBox(
|
|||
std::shared_ptr<Ui::Show> show,
|
||||
not_null<PeerData*> peer,
|
||||
const std::vector<MsgId> &ids,
|
||||
const std::vector<StoryId> &stories);
|
||||
const std::vector<StoryId> &stories,
|
||||
const style::ReportBox *stOverride = nullptr);
|
||||
|
|
|
@ -218,8 +218,11 @@ ComposeControls {
|
|||
|
||||
ReportBox {
|
||||
button: SettingsButton;
|
||||
noIconButton: SettingsButton;
|
||||
label: FlatLabel;
|
||||
field: InputField;
|
||||
dividerBg: color;
|
||||
dividerFg: color;
|
||||
spam: icon;
|
||||
fake: icon;
|
||||
violence: icon;
|
||||
|
@ -1360,8 +1363,13 @@ reportReasonButton: SettingsButton(defaultSettingsButton) {
|
|||
|
||||
defaultReportBox: ReportBox {
|
||||
button: reportReasonButton;
|
||||
noIconButton: SettingsButton(reportReasonButton) {
|
||||
padding: margins(22px, 7px, 8px, 7px);
|
||||
}
|
||||
label: boxLabel;
|
||||
field: newGroupDescription;
|
||||
dividerBg: boxDividerBg;
|
||||
dividerFg: windowSubTextFg;
|
||||
spam: menuIconDelete;
|
||||
fake: menuIconFake;
|
||||
violence: menuIconViolence;
|
||||
|
|
|
@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_stories.h"
|
||||
|
||||
#include "base/unixtime.h"
|
||||
#include "boxes/report_messages_box.h"
|
||||
#include "apiwrap.h"
|
||||
#include "core/application.h"
|
||||
#include "data/data_changes.h"
|
||||
|
@ -1905,17 +1904,6 @@ void Stories::togglePinnedList(
|
|||
|
||||
}
|
||||
|
||||
void Stories::report(
|
||||
std::shared_ptr<Ui::Show> show,
|
||||
FullStoryId id,
|
||||
Ui::ReportReason reason,
|
||||
QString text) {
|
||||
if (const auto maybeStory = lookup(id)) {
|
||||
const auto story = *maybeStory;
|
||||
ShowReportMessageBox(show, story->peer(), {}, { story->id() });
|
||||
}
|
||||
}
|
||||
|
||||
bool Stories::isQuitPrevent() {
|
||||
if (!_markReadPending.empty()) {
|
||||
sendMarkAsReadRequests();
|
||||
|
|
|
@ -19,7 +19,6 @@ class Session;
|
|||
|
||||
namespace Ui {
|
||||
class Show;
|
||||
enum class ReportReason;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Data {
|
||||
|
@ -216,11 +215,6 @@ public:
|
|||
bool pin) const;
|
||||
[[nodiscard]] int maxPinnedCount() const;
|
||||
void togglePinnedList(const std::vector<FullStoryId> &ids, bool pin);
|
||||
void report(
|
||||
std::shared_ptr<Ui::Show> show,
|
||||
FullStoryId id,
|
||||
Ui::ReportReason reason,
|
||||
QString text);
|
||||
|
||||
void incrementPreloadingMainSources();
|
||||
void decrementPreloadingMainSources();
|
||||
|
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/qt_signal_producer.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "boxes/peers/prepare_short_info_box.h"
|
||||
#include "boxes/report_messages_box.h"
|
||||
#include "chat_helpers/compose/compose_show.h"
|
||||
#include "core/application.h"
|
||||
#include "core/click_handler_types.h"
|
||||
|
@ -1896,16 +1897,12 @@ void ReportRequested(
|
|||
std::shared_ptr<Main::SessionShow> show,
|
||||
FullStoryId id,
|
||||
const style::ReportBox *stOverride) {
|
||||
const auto owner = &show->session().data();
|
||||
const auto st = stOverride ? stOverride : &st::defaultReportBox;
|
||||
show->show(Box(Ui::ReportReasonBox, *st, Ui::ReportSource::Story, [=](
|
||||
Ui::ReportReason reason) {
|
||||
const auto done = [=](const QString &text) {
|
||||
owner->stories().report(show, id, reason, text);
|
||||
show->hideLayer();
|
||||
};
|
||||
show->showBox(Box(Ui::ReportDetailsBox, *st, done));
|
||||
}));
|
||||
if (const auto maybeStory = show->session().data().stories().lookup(id)) {
|
||||
const auto story = *maybeStory;
|
||||
const auto st = stOverride ? stOverride : &st::defaultReportBox;
|
||||
// show->hideLayer();
|
||||
ShowReportMessageBox(show, story->peer(), {}, { story->id() }, st);
|
||||
}
|
||||
}
|
||||
|
||||
object_ptr<Ui::BoxContent> PrepareShortInfoBox(not_null<PeerData*> peer) {
|
||||
|
|
|
@ -888,11 +888,21 @@ storiesReportBox: ReportBox(defaultReportBox) {
|
|||
textBgOver: storiesComposeBgOver;
|
||||
ripple: storiesComposeRipple;
|
||||
}
|
||||
noIconButton: SettingsButton(reportReasonButton) {
|
||||
textFg: storiesComposeWhiteText;
|
||||
textFgOver: storiesComposeWhiteText;
|
||||
textBg: storiesComposeBg;
|
||||
textBgOver: storiesComposeBgOver;
|
||||
padding: margins(22px, 7px, 8px, 7px);
|
||||
ripple: storiesComposeRipple;
|
||||
}
|
||||
label: storiesBoxLabel;
|
||||
field: InputField(storiesBoxInputField) {
|
||||
textMargins: margins(1px, 26px, 1px, 4px);
|
||||
heightMax: 116px;
|
||||
}
|
||||
dividerBg: groupCallBg;
|
||||
dividerFg: groupCallVideoSubTextFg;
|
||||
spam: icon {{ "menu/delete", storiesComposeWhiteText }};
|
||||
fake: icon {{ "menu/fake", storiesComposeWhiteText }};
|
||||
violence: icon {{ "menu/violence", storiesComposeWhiteText }};
|
||||
|
|
|
@ -241,7 +241,8 @@ void ShowReportSponsoredBox(
|
|||
for (const auto &option : result.options) {
|
||||
const auto button = Ui::AddReportOptionButton(
|
||||
box->verticalLayout(),
|
||||
option.text);
|
||||
option.text,
|
||||
nullptr);
|
||||
button->setClickedCallback([=] {
|
||||
repeatRequest(repeatRequest, option.id);
|
||||
});
|
||||
|
|
|
@ -166,21 +166,26 @@ void ReportDetailsBox(
|
|||
|
||||
not_null<Ui::AbstractButton*> AddReportOptionButton(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
const QString &text) {
|
||||
const QString &text,
|
||||
const style::ReportBox *stOverride) {
|
||||
const auto button = container->add(
|
||||
object_ptr<Ui::SettingsButton>(
|
||||
container,
|
||||
rpl::single(QString()),
|
||||
st::settingsButtonNoIcon));
|
||||
(stOverride ? stOverride : &st::defaultReportBox)->noIconButton));
|
||||
const auto textFg = (stOverride
|
||||
? stOverride->label
|
||||
: st::sponsoredReportLabel).textFg->c;
|
||||
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
||||
button,
|
||||
rpl::single(text),
|
||||
st::sponsoredReportLabel);
|
||||
label->setTextColorOverride(textFg);
|
||||
const auto icon = Ui::CreateChild<Ui::RpWidget>(button);
|
||||
icon->resize(st::settingsPremiumArrow.size());
|
||||
icon->paintRequest() | rpl::start_with_next([=, w = icon->width()] {
|
||||
auto p = Painter(icon);
|
||||
st::settingsPremiumArrow.paint(p, 0, 0, w);
|
||||
st::settingsPremiumArrow.paint(p, 0, 0, w, textFg);
|
||||
}, icon->lifetime());
|
||||
button->sizeValue() | rpl::start_with_next([=](const QSize &size) {
|
||||
const auto left = button->st().padding.left();
|
||||
|
|
|
@ -56,7 +56,8 @@ void ReportDetailsBox(
|
|||
|
||||
[[nodiscard]] not_null<Ui::AbstractButton*> AddReportOptionButton(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
const QString &text);
|
||||
const QString &text,
|
||||
const style::ReportBox *stOverride);
|
||||
|
||||
void AddReportDetailsIconButton(not_null<GenericBox*> box);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue