2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-02 15:35:51 +00:00

Add 'Contact joined' notifications setting.

This commit is contained in:
John Preston
2019-01-18 13:24:10 +04:00
parent 01b7d4ffba
commit 61b9a32504
5 changed files with 99 additions and 5 deletions

View File

@@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwindow.h"
#include "messenger.h"
#include "auth_session.h"
#include "apiwrap.h"
#include "styles/style_settings.h"
#include "styles/style_boxes.h"
#include "styles/style_window.h"
@@ -512,6 +513,8 @@ void SetupAdvancedNotifications(not_null<Ui::VerticalLayout*> container) {
}
void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
AddSubsectionTitle(container, lng_settings_notify_title);
const auto checkbox = [&](LangKey label, bool checked) {
return object_ptr<Ui::Checkbox>(
container,
@@ -543,6 +546,12 @@ void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
const auto sound = addCheckbox(
lng_settings_sound_notify,
Global::SoundNotify());
AddSkip(container, st::settingsCheckboxesSkip);
AddDivider(container);
AddSkip(container, st::settingsCheckboxesSkip);
AddSubsectionTitle(container, lng_settings_badge_title);
const auto muted = addCheckbox(
lng_settings_include_muted,
Auth().settings().includeMutedCounter());
@@ -550,7 +559,27 @@ void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
lng_settings_count_unread,
Auth().settings().countUnreadMessages());
const auto nativeNotificationsKey = [&] {
AddSkip(container, st::settingsCheckboxesSkip);
AddDivider(container);
AddSkip(container, st::settingsCheckboxesSkip);
AddSubsectionTitle(container, lng_settings_events_title);
const auto joined = addCheckbox(
lng_settings_events_joined,
!Auth().api().contactSignupSilentCurrent().value_or(false));
Auth().api().contactSignupSilent(
) | rpl::start_with_next([=](bool silent) {
joined->setChecked(!silent);
}, joined->lifetime());
joined->checkedChanges(
) | rpl::filter([](bool enabled) {
const auto silent = Auth().api().contactSignupSilentCurrent();
return (enabled == silent.value_or(false));
}) | rpl::start_with_next([=](bool enabled) {
Auth().api().saveContactSignupSilent(!enabled);
}, joined->lifetime());
const auto nativeKey = [&] {
if (!Platform::Notifications::Supported()) {
return LangKey();
} else if (cPlatform() == dbipWindows) {
@@ -561,9 +590,17 @@ void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
}
return LangKey();
}();
const auto native = nativeNotificationsKey
? addCheckbox(nativeNotificationsKey, Global::NativeNotifications())
: nullptr;
const auto native = [&]() -> Ui::Checkbox* {
if (!nativeKey) {
return nullptr;
}
AddSkip(container, st::settingsCheckboxesSkip);
AddDivider(container);
AddSkip(container, st::settingsCheckboxesSkip);
AddSubsectionTitle(container, lng_settings_native_title);
return addCheckbox(nativeKey, Global::NativeNotifications());
}();
const auto advancedSlide = (cPlatform() != dbipMac)
? container->add(