2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Support disabling top peers completely.

This commit is contained in:
John Preston
2024-04-11 16:32:58 +04:00
parent e1c21b908c
commit c11f4efc5c
10 changed files with 125 additions and 35 deletions

View File

@@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "calls/calls_instance.h"
#include "core/update_checker.h"
#include "lang/lang_keys.h"
#include "data/components/top_peers.h"
#include "data/data_session.h"
#include "data/data_chat.h"
#include "data/data_channel.h"
@@ -546,6 +547,35 @@ void SetupCloudPassword(
session->api().cloudPassword().reload();
}
void SetupTopPeers(
not_null<Window::SessionController*> controller,
not_null<Ui::VerticalLayout*> container) {
Ui::AddSkip(container);
Ui::AddSubsectionTitle(container, tr::lng_settings_top_peers_title());
const auto session = &controller->session();
container->add(object_ptr<Button>(
container,
tr::lng_settings_top_peers_suggest(),
st::settingsButtonNoIcon
))->toggleOn(rpl::single(
rpl::empty
) | rpl::then(
session->topPeers().updates()
) | rpl::map([=] {
return !session->topPeers().disabled();
}))->toggledChanges(
) | rpl::filter([=](bool enabled) {
return enabled == session->topPeers().disabled();
}) | rpl::start_with_next([=](bool enabled) {
session->topPeers().toggleDisabled(!enabled);
}, container->lifetime());
Ui::AddSkip(container);
Ui::AddDividerText(container, tr::lng_settings_top_peers_about());
}
void SetupSensitiveContent(
not_null<Window::SessionController*> controller,
not_null<Ui::VerticalLayout*> container,
@@ -1065,6 +1095,7 @@ void PrivacySecurity::setupContent(
SetupSecurity(controller, content, trigger(), showOtherMethod());
SetupPrivacy(controller, content, trigger());
SetupTopPeers(controller, content);
#if !defined OS_MAC_STORE && !defined OS_WIN_STORE
SetupSensitiveContent(controller, content, trigger());
#else // !OS_MAC_STORE && !OS_WIN_STORE