diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index 8c5b3b7d2a..66ff7370a4 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -302,6 +302,42 @@ void ShowLanguagesBox(Window::SessionController *controller) { Guard = LanguageBox::Show(controller); } +void ShowPhonePrivacyBox(Window::SessionController *controller) { + static auto Guard = base::binary_guard(); + auto guard = base::binary_guard(); + + using Privacy = Api::UserPrivacy; + const auto key = Privacy::Key::PhoneNumber; + controller->session().api().userPrivacy().reload(key); + + const auto weak = base::make_weak(controller); + auto shared = std::make_shared( + guard.make_guard()); + auto lifetime = std::make_shared(); + controller->session().api().userPrivacy().value( + key + ) | rpl::take( + 1 + ) | rpl::start_with_next([=](const Privacy::Rule &value) mutable { + using namespace ::Settings; + const auto show = shared->alive(); + if (lifetime) { + base::take(lifetime)->destroy(); + } + if (show) { + if (const auto controller = weak.get()) { + controller->show(Box( + controller, + std::make_unique( + controller), + value)); + } + } + }, *lifetime); + + Guard = std::move(guard); +} + bool SetLanguage( Window::SessionController *controller, const Match &match, @@ -718,6 +754,9 @@ bool ResolveSettings( if (section == u"language"_q) { ShowLanguagesBox(controller); return {}; + } else if (section == u"phone_privacy"_q) { + ShowPhonePrivacyBox(controller); + return {}; } else if (section == u"devices"_q) { return ::Settings::Sessions::Id(); } else if (section == u"folders"_q) { @@ -1462,7 +1501,7 @@ const std::vector &LocalUrlHandlers() { ResolvePrivatePost }, { - u"^settings(/language|/devices|/folders|/privacy|/themes|/change_number|/auto_delete|/information|/edit_profile)?$"_q, + u"^settings(/language|/devices|/folders|/privacy|/themes|/change_number|/auto_delete|/information|/edit_profile|/phone_privacy)?$"_q, ResolveSettings }, {