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