mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-05-28 18:53:55 +02:00
Support tg://settings/phone_privacy links.
This commit is contained in:
parent
6d5d61c842
commit
8e6d23ddd6
1 changed files with 40 additions and 1 deletions
|
@ -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<base::binary_guard>(
|
||||
guard.make_guard());
|
||||
auto lifetime = std::make_shared<rpl::lifetime>();
|
||||
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<EditPrivacyBox>(
|
||||
controller,
|
||||
std::make_unique<PhoneNumberPrivacyController>(
|
||||
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<LocalUrlHandler> &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
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue