Verify age in sensitive toggle settings.

This commit is contained in:
John Preston 2025-07-21 17:03:36 +04:00
parent ccb8c43961
commit 427487c598
3 changed files with 42 additions and 4 deletions

View file

@ -403,6 +403,18 @@ void ShowAgeVerification(
- padding.right());
button->moveToLeft(padding.left(), padding.top());
}, button->lifetime());
const auto close = Ui::CreateChild<Ui::IconButton>(
box.get(),
st::boxTitleClose);
close->setClickedCallback([=] {
box->closeBox();
});
box->widthValue(
) | rpl::start_with_next([=](int width) {
close->moveToRight(0, 0);
}, box->lifetime());
crl::on_main(close, [=] { close->raise(); });
}));
}

View file

@ -19,10 +19,18 @@ namespace Data {
class Media;
} // namespace Data
namespace Main {
class Session;
} // namespace Main
namespace Media::Streaming {
struct ExpandDecision;
} // namespace Media::Streaming
namespace Ui {
class Show;
} // namespace Ui
namespace HistoryView {
class Media;
@ -75,6 +83,11 @@ void PaintInterpolatedIcon(
int newWidth,
int maxWidth);
void ShowAgeVerificationRequired(
std::shared_ptr<Ui::Show> show,
not_null<Main::Session*> session,
Fn<void()> reveal);
[[nodiscard]] ClickHandlerPtr MakePaidMediaLink(
not_null<HistoryItem*> item);
[[nodiscard]] ClickHandlerPtr MakeSensitiveMediaLink(

View file

@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/self_destruction_box.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "history/view/media/history_view_media_common.h"
#include "ui/chat/chat_style.h"
#include "ui/effects/premium_graphics.h"
#include "ui/effects/premium_top_bar.h"
@ -971,7 +972,9 @@ void SetupSensitiveContent(
Ui::AddSkip(inner);
Ui::AddSubsectionTitle(inner, tr::lng_settings_sensitive_title());
const auto show = controller->uiShow();
const auto session = &controller->session();
const auto disable = inner->lifetime().make_state<rpl::event_stream<>>();
std::move(
updateTrigger
@ -982,13 +985,23 @@ void SetupSensitiveContent(
inner,
tr::lng_settings_sensitive_disable_filtering(),
st::settingsButtonNoIcon
))->toggleOn(
session->api().sensitiveContent().enabled()
)->toggledChanges(
))->toggleOn(rpl::merge(
session->api().sensitiveContent().enabled(),
disable->events() | rpl::map_to(false)
))->toggledChanges(
) | rpl::filter([=](bool toggled) {
return toggled != session->api().sensitiveContent().enabledCurrent();
}) | rpl::start_with_next([=](bool toggled) {
session->api().sensitiveContent().update(toggled);
if (toggled && session->appConfig().ageVerifyNeeded()) {
disable->fire({});
HistoryView::ShowAgeVerificationRequired(
show,
session,
[] {});
} else {
session->api().sensitiveContent().update(toggled);
}
}, container->lifetime());
Ui::AddSkip(inner);