mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 15:43:55 +02:00
Added privacy link to birthday box from top bar suggestion.
This commit is contained in:
parent
ff67d876b2
commit
7e45283ba2
3 changed files with 58 additions and 8 deletions
|
@ -37,6 +37,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "passport/passport_form_controller.h"
|
#include "passport/passport_form_controller.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
|
#include "ui/vertical_list.h"
|
||||||
#include "data/components/credits.h"
|
#include "data/components/credits.h"
|
||||||
#include "data/data_birthday.h"
|
#include "data/data_birthday.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
|
@ -936,10 +937,41 @@ bool ShowEditBirthday(
|
||||||
: (u"Error: "_q + error.type()));
|
: (u"Error: "_q + error.type()));
|
||||||
})).handleFloodErrors().send();
|
})).handleFloodErrors().send();
|
||||||
};
|
};
|
||||||
controller->show(Box(
|
if (match->captured(1).isEmpty()) {
|
||||||
Ui::EditBirthdayBox,
|
controller->show(Box(Ui::EditBirthdayBox, user->birthday(), save));
|
||||||
user->birthday(),
|
} else {
|
||||||
save));
|
controller->show(Box([=](not_null<Ui::GenericBox*> box) {
|
||||||
|
Ui::EditBirthdayBox(box, user->birthday(), save);
|
||||||
|
|
||||||
|
const auto container = box->verticalLayout();
|
||||||
|
const auto session = &user->session();
|
||||||
|
const auto key = Api::UserPrivacy::Key::Birthday;
|
||||||
|
session->api().userPrivacy().reload(key);
|
||||||
|
auto isExactlyContacts = session->api().userPrivacy().value(
|
||||||
|
key
|
||||||
|
) | rpl::map([=](const Api::UserPrivacy::Rule &value) {
|
||||||
|
return (value.option == Api::UserPrivacy::Option::Contacts)
|
||||||
|
&& value.always.peers.empty()
|
||||||
|
&& !value.always.premiums
|
||||||
|
&& value.never.peers.empty();
|
||||||
|
}) | rpl::distinct_until_changed();
|
||||||
|
Ui::AddSkip(container);
|
||||||
|
const auto link = u"internal:edit_privacy_birthday:from_box"_q;
|
||||||
|
Ui::AddDividerText(container, rpl::conditional(
|
||||||
|
std::move(isExactlyContacts),
|
||||||
|
tr::lng_settings_birthday_contacts(
|
||||||
|
lt_link,
|
||||||
|
tr::lng_settings_birthday_contacts_link(
|
||||||
|
) | Ui::Text::ToLink(link),
|
||||||
|
Ui::Text::WithEntities),
|
||||||
|
tr::lng_settings_birthday_about(
|
||||||
|
lt_link,
|
||||||
|
tr::lng_settings_birthday_about_link(
|
||||||
|
) | Ui::Text::ToLink(link),
|
||||||
|
Ui::Text::WithEntities)));
|
||||||
|
}));
|
||||||
|
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -950,11 +982,29 @@ bool ShowEditBirthdayPrivacy(
|
||||||
if (!controller) {
|
if (!controller) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
const auto isFromBox = !match->captured(1).isEmpty();
|
||||||
auto syncLifetime = controller->session().api().userPrivacy().value(
|
auto syncLifetime = controller->session().api().userPrivacy().value(
|
||||||
Api::UserPrivacy::Key::Birthday
|
Api::UserPrivacy::Key::Birthday
|
||||||
) | rpl::take(
|
) | rpl::take(
|
||||||
1
|
1
|
||||||
) | rpl::start_with_next([=](const Api::UserPrivacy::Rule &value) {
|
) | rpl::start_with_next([=](const Api::UserPrivacy::Rule &value) {
|
||||||
|
if (isFromBox) {
|
||||||
|
using namespace ::Settings;
|
||||||
|
class Controller final : public BirthdayPrivacyController {
|
||||||
|
object_ptr<Ui::RpWidget> setupAboveWidget(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<QWidget*> parent,
|
||||||
|
rpl::producer<Option> optionValue,
|
||||||
|
not_null<QWidget*> outerContainer) override {
|
||||||
|
return { nullptr };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
controller->show(Box<EditPrivacyBox>(
|
||||||
|
controller,
|
||||||
|
std::make_unique<Controller>(),
|
||||||
|
value));
|
||||||
|
return;
|
||||||
|
}
|
||||||
controller->show(Box<EditPrivacyBox>(
|
controller->show(Box<EditPrivacyBox>(
|
||||||
controller,
|
controller,
|
||||||
std::make_unique<::Settings::BirthdayPrivacyController>(),
|
std::make_unique<::Settings::BirthdayPrivacyController>(),
|
||||||
|
@ -1595,11 +1645,11 @@ const std::vector<LocalUrlHandler> &InternalUrlHandlers() {
|
||||||
ShowSearchTagsPromo
|
ShowSearchTagsPromo
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
u"^edit_birthday$"_q,
|
u"^edit_birthday(.*)$"_q,
|
||||||
ShowEditBirthday,
|
ShowEditBirthday,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
u"^edit_privacy_birthday$"_q,
|
u"^edit_privacy_birthday(.*)$"_q,
|
||||||
ShowEditBirthdayPrivacy,
|
ShowEditBirthdayPrivacy,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -360,7 +360,7 @@ rpl::producer<Ui::SlideWrap<Ui::RpWidget>*> TopBarSuggestionValue(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Core::App().openInternalUrl(
|
Core::App().openInternalUrl(
|
||||||
u"internal:edit_birthday"_q,
|
u"internal:edit_birthday:add_privacy"_q,
|
||||||
QVariant::fromValue(ClickHandlerContext{
|
QVariant::fromValue(ClickHandlerContext{
|
||||||
.sessionWindow = base::make_weak(controller),
|
.sessionWindow = base::make_weak(controller),
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -317,7 +317,7 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class BirthdayPrivacyController final : public EditPrivacyController {
|
class BirthdayPrivacyController : public EditPrivacyController {
|
||||||
public:
|
public:
|
||||||
using Option = EditPrivacyBox::Option;
|
using Option = EditPrivacyBox::Option;
|
||||||
using Exception = EditPrivacyBox::Exception;
|
using Exception = EditPrivacyBox::Exception;
|
||||||
|
|
Loading…
Add table
Reference in a new issue