2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-05 08:55:59 +00:00

Update API scheme to layer 172.

This commit is contained in:
John Preston
2024-01-09 13:13:30 +04:00
parent c364383cf0
commit ca25ad57b1
16 changed files with 295 additions and 81 deletions

View File

@@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "settings/settings_privacy_controllers.h"
#include "api/api_global_privacy.h"
#include "api/api_peer_photo.h"
#include "apiwrap.h"
#include "base/call_delayed.h"
@@ -36,6 +37,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/history_view_message.h"
#include "lang/lang_keys.h"
#include "main/main_session.h"
#include "settings/settings_premium.h"
#include "settings/settings_privacy_security.h"
#include "ui/boxes/confirm_box.h"
#include "ui/cached_round_corners.h"
@@ -665,16 +667,64 @@ auto LastSeenPrivacyController::exceptionsDescription() const
return tr::lng_edit_privacy_lastseen_exceptions();
}
object_ptr<Ui::RpWidget> LastSeenPrivacyController::setupBelowWidget(
not_null<Window::SessionController*> controller,
not_null<QWidget*> parent) {
auto result = object_ptr<Ui::VerticalLayout>(parent);
const auto content = result.data();
Ui::AddSkip(content);
const auto privacy = &controller->session().api().globalPrivacy();
content->add(object_ptr<Ui::SettingsButton>(
content,
tr::lng_edit_lastseen_hide_read_time(),
st::settingsButtonNoIcon
))->toggleOn(privacy->hideReadTime())->toggledValue(
) | rpl::start_with_next([=](bool value) {
_hideReadTime = value;
}, content->lifetime());
Ui::AddSkip(content);
Ui::AddDividerText(
content,
tr::lng_edit_lastseen_hide_read_time_about());
if (!controller->session().premium()) {
Ui::AddSkip(content);
content->add(object_ptr<Ui::SettingsButton>(
content,
tr::lng_edit_lastseen_subscribe(),
st::settingsButtonLightNoIcon
))->setClickedCallback([=] {
Settings::ShowPremium(controller, u"lastseen"_q);
});
Ui::AddSkip(content);
Ui::AddDividerText(
content,
tr::lng_edit_lastseen_subscribe_about());
}
return result;
}
void LastSeenPrivacyController::confirmSave(
bool someAreDisallowed,
Fn<void()> saveCallback) {
const auto privacy = &_session->api().globalPrivacy();
const auto hideReadTime = _hideReadTime;
const auto save = [=, saveCallback = std::move(saveCallback)] {
if (privacy->hideReadTimeCurrent() != hideReadTime) {
privacy->updateHideReadTime(hideReadTime);
}
saveCallback();
};
if (someAreDisallowed && !Core::App().settings().lastSeenWarningSeen()) {
auto callback = [
=,
saveCallback = std::move(saveCallback)
save = std::move(save)
](Fn<void()> &&close) {
close();
saveCallback();
save();
Core::App().settings().setLastSeenWarningSeen(true);
Core::App().saveSettingsDelayed();
};
@@ -685,7 +735,7 @@ void LastSeenPrivacyController::confirmSave(
});
Ui::show(std::move(box), Ui::LayerOption::KeepOther);
} else {
saveCallback();
save();
}
}