2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-05 09:05:14 +00:00

Refactor NotifySettings in PeerData.

This commit is contained in:
John Preston
2017-12-04 21:46:03 +04:00
parent 116e3fd9c5
commit 62568daffe
21 changed files with 562 additions and 290 deletions

View File

@@ -357,7 +357,7 @@ void WrapWidget::addProfileMenuButton() {
void WrapWidget::addProfileNotificationsButton() {
Expects(_topBar != nullptr);
auto peer = _controller->peer();
const auto peer = _controller->peer();
auto notifications = _topBar->addButton(
base::make_unique_q<Ui::IconButton>(
_topBar,
@@ -365,18 +365,17 @@ void WrapWidget::addProfileNotificationsButton() {
? st::infoLayerTopBarNotifications
: st::infoTopBarNotifications)));
notifications->addClickHandler([peer] {
App::main()->updateNotifySetting(
peer,
peer->isMuted()
? NotifySettingSetNotify
: NotifySettingSetMuted);
const auto muteState = peer->isMuted()
? Data::NotifySettings::MuteChange::Unmute
: Data::NotifySettings::MuteChange::Mute;
App::main()->updateNotifySettings(peer, muteState);
});
Profile::NotificationsEnabledValue(peer)
| rpl::start_with_next([notifications](bool enabled) {
auto iconOverride = enabled
const auto iconOverride = enabled
? &st::infoNotificationsActive
: nullptr;
auto rippleOverride = enabled
const auto rippleOverride = enabled
? &st::lightButtonBgOver
: nullptr;
notifications->setIconOverride(iconOverride, iconOverride);