mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Moved out public api for notify settings from Data::Session.
This commit is contained in:
parent
36bb23c54c
commit
9478798a47
13 changed files with 113 additions and 114 deletions
|
@ -3798,66 +3798,6 @@ auto Session::dialogsRowReplacements() const
|
||||||
return _dialogsRowReplacements.events();
|
return _dialogsRowReplacements.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Session::notifyIsMuted(not_null<const PeerData*> peer) const {
|
|
||||||
return notifySettings().notifyIsMuted(peer, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Session::notifySilentPosts(not_null<const PeerData*> peer) const {
|
|
||||||
if (const auto silent = peer->notifySilentPosts()) {
|
|
||||||
return *silent;
|
|
||||||
}
|
|
||||||
const auto &settings = notifySettings().defaultNotifySettings(peer);
|
|
||||||
if (const auto silent = settings.silentPosts()) {
|
|
||||||
return *silent;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Session::notifySoundIsNone(not_null<const PeerData*> peer) const {
|
|
||||||
if (const auto soundIsNone = peer->notifySoundIsNone()) {
|
|
||||||
return *soundIsNone;
|
|
||||||
}
|
|
||||||
const auto &settings = notifySettings().defaultNotifySettings(peer);
|
|
||||||
if (const auto soundIsNone = settings.soundIsNone()) {
|
|
||||||
return *soundIsNone;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Session::notifyMuteUnknown(not_null<const PeerData*> peer) const {
|
|
||||||
if (peer->notifySettingsUnknown()) {
|
|
||||||
return true;
|
|
||||||
} else if (const auto nonDefault = peer->notifyMuteUntil()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return notifySettings().defaultNotifySettings(peer).settingsUnknown();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Session::notifySilentPostsUnknown(
|
|
||||||
not_null<const PeerData*> peer) const {
|
|
||||||
if (peer->notifySettingsUnknown()) {
|
|
||||||
return true;
|
|
||||||
} else if (const auto nonDefault = peer->notifySilentPosts()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return notifySettings().defaultNotifySettings(peer).settingsUnknown();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Session::notifySoundIsNoneUnknown(not_null<const PeerData*> peer) const {
|
|
||||||
if (peer->notifySettingsUnknown()) {
|
|
||||||
return true;
|
|
||||||
} else if (const auto nonDefault = peer->notifySoundIsNone()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return notifySettings().defaultNotifySettings(peer).settingsUnknown();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Session::notifySettingsUnknown(not_null<const PeerData*> peer) const {
|
|
||||||
return notifyMuteUnknown(peer)
|
|
||||||
|| notifySilentPostsUnknown(peer)
|
|
||||||
|| notifySoundIsNoneUnknown(peer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Session::serviceNotification(
|
void Session::serviceNotification(
|
||||||
const TextWithEntities &message,
|
const TextWithEntities &message,
|
||||||
const MTPMessageMedia &media) {
|
const MTPMessageMedia &media) {
|
||||||
|
|
|
@ -662,14 +662,6 @@ public:
|
||||||
void dialogsRowReplaced(DialogsRowReplacement replacement);
|
void dialogsRowReplaced(DialogsRowReplacement replacement);
|
||||||
rpl::producer<DialogsRowReplacement> dialogsRowReplacements() const;
|
rpl::producer<DialogsRowReplacement> dialogsRowReplacements() const;
|
||||||
|
|
||||||
bool notifyIsMuted(not_null<const PeerData*> peer) const;
|
|
||||||
bool notifySilentPosts(not_null<const PeerData*> peer) const;
|
|
||||||
bool notifySoundIsNone(not_null<const PeerData*> peer) const;
|
|
||||||
bool notifyMuteUnknown(not_null<const PeerData*> peer) const;
|
|
||||||
bool notifySilentPostsUnknown(not_null<const PeerData*> peer) const;
|
|
||||||
bool notifySoundIsNoneUnknown(not_null<const PeerData*> peer) const;
|
|
||||||
bool notifySettingsUnknown(not_null<const PeerData*> peer) const;
|
|
||||||
|
|
||||||
void serviceNotification(
|
void serviceNotification(
|
||||||
const TextWithEntities &message,
|
const TextWithEntities &message,
|
||||||
const MTPMessageMedia &media = MTP_messageMediaEmpty());
|
const MTPMessageMedia &media = MTP_messageMediaEmpty());
|
||||||
|
|
|
@ -130,16 +130,6 @@ void NotifySettings::resetNotifySettingsToDefault(not_null<PeerData*> peer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PeerNotifySettings &NotifySettings::defaultNotifySettings(
|
|
||||||
not_null<const PeerData*> peer) {
|
|
||||||
return peer->isUser()
|
|
||||||
? _defaultUserNotifySettings
|
|
||||||
: (peer->isChat() || peer->isMegagroup())
|
|
||||||
? _defaultChatNotifySettings
|
|
||||||
: _defaultBroadcastNotifySettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
const PeerNotifySettings &NotifySettings::defaultNotifySettings(
|
const PeerNotifySettings &NotifySettings::defaultNotifySettings(
|
||||||
not_null<const PeerData*> peer) const {
|
not_null<const PeerData*> peer) const {
|
||||||
return peer->isUser()
|
return peer->isUser()
|
||||||
|
@ -152,7 +142,7 @@ const PeerNotifySettings &NotifySettings::defaultNotifySettings(
|
||||||
void NotifySettings::updateNotifySettingsLocal(not_null<PeerData*> peer) {
|
void NotifySettings::updateNotifySettingsLocal(not_null<PeerData*> peer) {
|
||||||
const auto history = _owner->historyLoaded(peer->id);
|
const auto history = _owner->historyLoaded(peer->id);
|
||||||
auto changesIn = crl::time(0);
|
auto changesIn = crl::time(0);
|
||||||
const auto muted = notifyIsMuted(peer, &changesIn);
|
const auto muted = isMuted(peer, &changesIn);
|
||||||
if (history && history->changeMute(muted)) {
|
if (history && history->changeMute(muted)) {
|
||||||
// Notification already sent.
|
// Notification already sent.
|
||||||
} else {
|
} else {
|
||||||
|
@ -185,7 +175,7 @@ void NotifySettings::unmuteByFinished() {
|
||||||
for (auto i = begin(_mutedPeers); i != end(_mutedPeers);) {
|
for (auto i = begin(_mutedPeers); i != end(_mutedPeers);) {
|
||||||
const auto history = _owner->historyLoaded((*i)->id);
|
const auto history = _owner->historyLoaded((*i)->id);
|
||||||
auto changesIn = crl::time(0);
|
auto changesIn = crl::time(0);
|
||||||
const auto muted = notifyIsMuted(*i, &changesIn);
|
const auto muted = isMuted(*i, &changesIn);
|
||||||
if (muted) {
|
if (muted) {
|
||||||
if (history) {
|
if (history) {
|
||||||
history->changeMute(true);
|
history->changeMute(true);
|
||||||
|
@ -206,7 +196,7 @@ void NotifySettings::unmuteByFinished() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NotifySettings::notifyIsMuted(
|
bool NotifySettings::isMuted(
|
||||||
not_null<const PeerData*> peer,
|
not_null<const PeerData*> peer,
|
||||||
crl::time *changesIn) const {
|
crl::time *changesIn) const {
|
||||||
const auto resultFromUntil = [&](TimeId until) {
|
const auto resultFromUntil = [&](TimeId until) {
|
||||||
|
@ -229,6 +219,67 @@ bool NotifySettings::notifyIsMuted(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NotifySettings::isMuted(not_null<const PeerData*> peer) const {
|
||||||
|
return isMuted(peer, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NotifySettings::silentPosts(not_null<const PeerData*> peer) const {
|
||||||
|
if (const auto silent = peer->notifySilentPosts()) {
|
||||||
|
return *silent;
|
||||||
|
}
|
||||||
|
const auto &settings = defaultNotifySettings(peer);
|
||||||
|
if (const auto silent = settings.silentPosts()) {
|
||||||
|
return *silent;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NotifySettings::soundIsNone(not_null<const PeerData*> peer) const {
|
||||||
|
if (const auto soundIsNone = peer->notifySoundIsNone()) {
|
||||||
|
return *soundIsNone;
|
||||||
|
}
|
||||||
|
const auto &settings = defaultNotifySettings(peer);
|
||||||
|
if (const auto soundIsNone = settings.soundIsNone()) {
|
||||||
|
return *soundIsNone;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NotifySettings::muteUnknown(not_null<const PeerData*> peer) const {
|
||||||
|
if (peer->notifySettingsUnknown()) {
|
||||||
|
return true;
|
||||||
|
} else if (const auto nonDefault = peer->notifyMuteUntil()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return defaultNotifySettings(peer).settingsUnknown();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NotifySettings::silentPostsUnknown(
|
||||||
|
not_null<const PeerData*> peer) const {
|
||||||
|
if (peer->notifySettingsUnknown()) {
|
||||||
|
return true;
|
||||||
|
} else if (const auto nonDefault = peer->notifySilentPosts()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return defaultNotifySettings(peer).settingsUnknown();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NotifySettings::soundIsNoneUnknown(
|
||||||
|
not_null<const PeerData*> peer) const {
|
||||||
|
if (peer->notifySettingsUnknown()) {
|
||||||
|
return true;
|
||||||
|
} else if (const auto nonDefault = peer->notifySoundIsNone()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return defaultNotifySettings(peer).settingsUnknown();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NotifySettings::settingsUnknown(not_null<const PeerData*> peer) const {
|
||||||
|
return muteUnknown(peer)
|
||||||
|
|| silentPostsUnknown(peer)
|
||||||
|
|| soundIsNoneUnknown(peer);
|
||||||
|
}
|
||||||
|
|
||||||
rpl::producer<> NotifySettings::defaultUserNotifyUpdates() const {
|
rpl::producer<> NotifySettings::defaultUserNotifyUpdates() const {
|
||||||
return _defaultUserNotifyUpdates.events();
|
return _defaultUserNotifyUpdates.events();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,15 +38,24 @@ public:
|
||||||
[[nodiscard]] rpl::producer<> defaultNotifyUpdates(
|
[[nodiscard]] rpl::producer<> defaultNotifyUpdates(
|
||||||
not_null<const PeerData*> peer) const;
|
not_null<const PeerData*> peer) const;
|
||||||
|
|
||||||
[[nodiscard]] bool notifyIsMuted(
|
[[nodiscard]] bool isMuted(not_null<const PeerData*> peer) const;
|
||||||
|
[[nodiscard]] bool silentPosts(not_null<const PeerData*> peer) const;
|
||||||
|
[[nodiscard]] bool soundIsNone(not_null<const PeerData*> peer) const;
|
||||||
|
[[nodiscard]] bool muteUnknown(not_null<const PeerData*> peer) const;
|
||||||
|
[[nodiscard]] bool silentPostsUnknown(
|
||||||
|
not_null<const PeerData*> peer) const;
|
||||||
|
[[nodiscard]] bool soundIsNoneUnknown(
|
||||||
|
not_null<const PeerData*> peer) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
[[nodiscard]] bool isMuted(
|
||||||
not_null<const PeerData*> peer,
|
not_null<const PeerData*> peer,
|
||||||
crl::time *changesIn) const;
|
crl::time *changesIn) const;
|
||||||
|
|
||||||
[[nodiscard]] PeerNotifySettings &defaultNotifySettings(
|
|
||||||
not_null<const PeerData*> peer);
|
|
||||||
[[nodiscard]] const PeerNotifySettings &defaultNotifySettings(
|
[[nodiscard]] const PeerNotifySettings &defaultNotifySettings(
|
||||||
not_null<const PeerData*> peer) const;
|
not_null<const PeerData*> peer) const;
|
||||||
private:
|
[[nodiscard]] bool settingsUnknown(not_null<const PeerData*> peer) const;
|
||||||
|
|
||||||
void unmuteByFinished();
|
void unmuteByFinished();
|
||||||
void unmuteByFinishedDelayed(crl::time delay);
|
void unmuteByFinishedDelayed(crl::time delay);
|
||||||
void updateNotifySettingsLocal(not_null<PeerData*> peer);
|
void updateNotifySettingsLocal(not_null<PeerData*> peer);
|
||||||
|
|
|
@ -71,7 +71,7 @@ History::History(not_null<Data::Session*> owner, PeerId peerId)
|
||||||
, peer(owner->peer(peerId))
|
, peer(owner->peer(peerId))
|
||||||
, cloudDraftTextCache(st::dialogsTextWidthMin)
|
, cloudDraftTextCache(st::dialogsTextWidthMin)
|
||||||
, _delegateMixin(HistoryInner::DelegateMixin())
|
, _delegateMixin(HistoryInner::DelegateMixin())
|
||||||
, _mute(owner->notifyIsMuted(peer))
|
, _mute(owner->notifySettings().isMuted(peer))
|
||||||
, _chatListNameSortKey(owner->nameSortKey(peer->name))
|
, _chatListNameSortKey(owner->nameSortKey(peer->name))
|
||||||
, _sendActionPainter(this) {
|
, _sendActionPainter(this) {
|
||||||
if (const auto user = peer->asUser()) {
|
if (const auto user = peer->asUser()) {
|
||||||
|
|
|
@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/ui_integration.h"
|
#include "core/ui_integration.h"
|
||||||
#include "storage/storage_shared_media.h"
|
#include "storage/storage_shared_media.h"
|
||||||
#include "mtproto/mtproto_config.h"
|
#include "mtproto/mtproto_config.h"
|
||||||
|
#include "data/notify/data_notify_settings.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_changes.h"
|
#include "data/data_changes.h"
|
||||||
#include "data/data_media_types.h"
|
#include "data/data_media_types.h"
|
||||||
|
@ -198,7 +199,8 @@ bool ShouldSendSilent(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const Api::SendOptions &options) {
|
const Api::SendOptions &options) {
|
||||||
return options.silent
|
return options.silent
|
||||||
|| (peer->isBroadcast() && peer->owner().notifySilentPosts(peer))
|
|| (peer->isBroadcast()
|
||||||
|
&& peer->owner().notifySettings().silentPosts(peer))
|
||||||
|| (peer->session().supportMode()
|
|| (peer->session().supportMode()
|
||||||
&& peer->session().settings().supportAllSilent());
|
&& peer->session().settings().supportAllSilent());
|
||||||
}
|
}
|
||||||
|
|
|
@ -2499,9 +2499,10 @@ void HistoryWidget::updateNotifyControls() {
|
||||||
_muteUnmute->setText((_history->mute()
|
_muteUnmute->setText((_history->mute()
|
||||||
? tr::lng_channel_unmute(tr::now)
|
? tr::lng_channel_unmute(tr::now)
|
||||||
: tr::lng_channel_mute(tr::now)).toUpper());
|
: tr::lng_channel_mute(tr::now)).toUpper());
|
||||||
if (!session().data().notifySilentPostsUnknown(_peer)) {
|
if (!session().data().notifySettings().silentPostsUnknown(_peer)) {
|
||||||
if (_silent) {
|
if (_silent) {
|
||||||
_silent->setChecked(session().data().notifySilentPosts(_peer));
|
_silent->setChecked(
|
||||||
|
session().data().notifySettings().silentPosts(_peer));
|
||||||
updateFieldPlaceholder();
|
updateFieldPlaceholder();
|
||||||
} else if (hasSilentToggle()) {
|
} else if (hasSilentToggle()) {
|
||||||
refreshSilentToggle();
|
refreshSilentToggle();
|
||||||
|
@ -4286,7 +4287,7 @@ bool HistoryWidget::hasSilentToggle() const {
|
||||||
&& _peer->isChannel()
|
&& _peer->isChannel()
|
||||||
&& !_peer->isMegagroup()
|
&& !_peer->isMegagroup()
|
||||||
&& _peer->canWrite()
|
&& _peer->canWrite()
|
||||||
&& !session().data().notifySilentPostsUnknown(_peer);
|
&& !session().data().notifySettings().silentPostsUnknown(_peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::handleSupportSwitch(not_null<History*> updated) {
|
void HistoryWidget::handleSupportSwitch(not_null<History*> updated) {
|
||||||
|
@ -4832,7 +4833,7 @@ void HistoryWidget::updateFieldPlaceholder() {
|
||||||
return rpl::single(_keyboard->placeholder());
|
return rpl::single(_keyboard->placeholder());
|
||||||
} else if (const auto channel = _history->peer->asChannel()) {
|
} else if (const auto channel = _history->peer->asChannel()) {
|
||||||
if (channel->isBroadcast()) {
|
if (channel->isBroadcast()) {
|
||||||
return session().data().notifySilentPosts(channel)
|
return session().data().notifySettings().silentPosts(channel)
|
||||||
? tr::lng_broadcast_silent_ph()
|
? tr::lng_broadcast_silent_ph()
|
||||||
: tr::lng_broadcast_ph();
|
: tr::lng_broadcast_ph();
|
||||||
} else if (channel->adminRights() & ChatAdminRight::Anonymous) {
|
} else if (channel->adminRights() & ChatAdminRight::Anonymous) {
|
||||||
|
|
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "chat_helpers/field_autocomplete.h"
|
#include "chat_helpers/field_autocomplete.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/core_settings.h"
|
#include "core/core_settings.h"
|
||||||
|
#include "data/notify/data_notify_settings.h"
|
||||||
#include "data/data_changes.h"
|
#include "data/data_changes.h"
|
||||||
#include "data/data_drafts.h"
|
#include "data/data_drafts.h"
|
||||||
#include "data/data_messages.h"
|
#include "data/data_messages.h"
|
||||||
|
@ -1338,7 +1339,7 @@ void ComposeControls::updateFieldPlaceholder() {
|
||||||
return tr::lng_message_ph();
|
return tr::lng_message_ph();
|
||||||
} else if (const auto channel = _history->peer->asChannel()) {
|
} else if (const auto channel = _history->peer->asChannel()) {
|
||||||
if (channel->isBroadcast()) {
|
if (channel->isBroadcast()) {
|
||||||
return session().data().notifySilentPosts(channel)
|
return session().data().notifySettings().silentPosts(channel)
|
||||||
? tr::lng_broadcast_silent_ph()
|
? tr::lng_broadcast_silent_ph()
|
||||||
: tr::lng_broadcast_ph();
|
: tr::lng_broadcast_ph();
|
||||||
} else if (channel->adminRights() & ChatAdminRight::Anonymous) {
|
} else if (channel->adminRights() & ChatAdminRight::Anonymous) {
|
||||||
|
@ -1358,8 +1359,9 @@ void ComposeControls::updateSilentBroadcast() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto &peer = _history->peer;
|
const auto &peer = _history->peer;
|
||||||
if (!session().data().notifySilentPostsUnknown(peer)) {
|
if (!session().data().notifySettings().silentPostsUnknown(peer)) {
|
||||||
_silent->setChecked(session().data().notifySilentPosts(peer));
|
_silent->setChecked(
|
||||||
|
session().data().notifySettings().silentPosts(peer));
|
||||||
updateFieldPlaceholder();
|
updateFieldPlaceholder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2465,7 +2467,7 @@ bool ComposeControls::hasSilentBroadcastToggle() const {
|
||||||
&& peer->isChannel()
|
&& peer->isChannel()
|
||||||
&& !peer->isMegagroup()
|
&& !peer->isMegagroup()
|
||||||
&& peer->canWrite()
|
&& peer->canWrite()
|
||||||
&& !session().data().notifySilentPostsUnknown(peer);
|
&& !session().data().notifySettings().silentPostsUnknown(peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComposeControls::updateInlineBotQuery() {
|
void ComposeControls::updateInlineBotQuery() {
|
||||||
|
|
|
@ -174,7 +174,7 @@ rpl::producer<bool> NotificationsEnabledValue(not_null<PeerData*> peer) {
|
||||||
) | rpl::to_empty,
|
) | rpl::to_empty,
|
||||||
peer->owner().notifySettings().defaultNotifyUpdates(peer)
|
peer->owner().notifySettings().defaultNotifyUpdates(peer)
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return !peer->owner().notifyIsMuted(peer);
|
return !peer->owner().notifySettings().isMuted(peer);
|
||||||
}) | rpl::distinct_until_changed();
|
}) | rpl::distinct_until_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ MuteItem::MuteItem(
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr)
|
nullptr)
|
||||||
, _itemIconPosition(st.itemIconPosition)
|
, _itemIconPosition(st.itemIconPosition)
|
||||||
, _isMuted(peer->owner().notifyIsMuted(peer)) {
|
, _isMuted(peer->owner().notifySettings().isMuted(peer)) {
|
||||||
|
|
||||||
Info::Profile::NotificationsEnabledValue(
|
Info::Profile::NotificationsEnabledValue(
|
||||||
peer
|
peer
|
||||||
|
@ -135,14 +135,14 @@ void FillMuteMenu(
|
||||||
Args args) {
|
Args args) {
|
||||||
const auto peer = args.peer;
|
const auto peer = args.peer;
|
||||||
|
|
||||||
const auto soundIsNone = peer->owner().notifySoundIsNone(peer);
|
const auto soundIsNone = peer->owner().notifySettings().soundIsNone(peer);
|
||||||
menu->addAction(
|
menu->addAction(
|
||||||
soundIsNone
|
soundIsNone
|
||||||
? tr::lng_mute_menu_sound_on(tr::now)
|
? tr::lng_mute_menu_sound_on(tr::now)
|
||||||
: tr::lng_mute_menu_sound_off(tr::now),
|
: tr::lng_mute_menu_sound_off(tr::now),
|
||||||
[=] {
|
[=] {
|
||||||
const auto soundIsNone = peer->owner().notifySoundIsNone(peer);
|
|
||||||
auto ¬ifySettings = peer->owner().notifySettings();
|
auto ¬ifySettings = peer->owner().notifySettings();
|
||||||
|
const auto soundIsNone = notifySettings.soundIsNone(peer);
|
||||||
notifySettings.updateNotifySettings(peer, {}, {}, !soundIsNone);
|
notifySettings.updateNotifySettings(peer, {}, {}, !soundIsNone);
|
||||||
},
|
},
|
||||||
soundIsNone ? &st::menuIconSoundOn : &st::menuIconSoundOff);
|
soundIsNone ? &st::menuIconSoundOn : &st::menuIconSoundOff);
|
||||||
|
|
|
@ -812,8 +812,8 @@ SilentToggle::SilentToggle(QWidget *parent, not_null<ChannelData*> channel)
|
||||||
: RippleButton(parent, st::historySilentToggle.ripple)
|
: RippleButton(parent, st::historySilentToggle.ripple)
|
||||||
, _st(st::historySilentToggle)
|
, _st(st::historySilentToggle)
|
||||||
, _channel(channel)
|
, _channel(channel)
|
||||||
, _checked(channel->owner().notifySilentPosts(_channel)) {
|
, _checked(channel->owner().notifySettings().silentPosts(_channel)) {
|
||||||
Expects(!channel->owner().notifySilentPostsUnknown(_channel));
|
Expects(!channel->owner().notifySettings().silentPostsUnknown(_channel));
|
||||||
|
|
||||||
resize(_st.width, _st.height);
|
resize(_st.width, _st.height);
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,8 @@ System::SkipState System::computeSkipState(
|
||||||
.silent = (forceSilent
|
.silent = (forceSilent
|
||||||
|| !messageNotification
|
|| !messageNotification
|
||||||
|| item->isSilent()
|
|| item->isSilent()
|
||||||
|| history->owner().notifySoundIsNone(history->peer)),
|
|| history->owner().notifySettings().soundIsNone(
|
||||||
|
history->peer)),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
const auto showForMuted = messageNotification
|
const auto showForMuted = messageNotification
|
||||||
|
@ -207,20 +208,20 @@ System::SkipState System::computeSkipState(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (messageNotification
|
if (messageNotification
|
||||||
&& history->owner().notifyMuteUnknown(history->peer)) {
|
&& history->owner().notifySettings().muteUnknown(history->peer)) {
|
||||||
return { SkipState::Unknown };
|
return { SkipState::Unknown };
|
||||||
} else if (messageNotification
|
} else if (messageNotification
|
||||||
&& !history->owner().notifyIsMuted(history->peer)) {
|
&& !history->owner().notifySettings().isMuted(history->peer)) {
|
||||||
return withSilent(SkipState::DontSkip);
|
return withSilent(SkipState::DontSkip);
|
||||||
} else if (!notifyBy) {
|
} else if (!notifyBy) {
|
||||||
return withSilent(
|
return withSilent(
|
||||||
showForMuted ? SkipState::DontSkip : SkipState::Skip,
|
showForMuted ? SkipState::DontSkip : SkipState::Skip,
|
||||||
showForMuted);
|
showForMuted);
|
||||||
} else if (history->owner().notifyMuteUnknown(notifyBy)
|
} else if (history->owner().notifySettings().muteUnknown(notifyBy)
|
||||||
|| (!messageNotification
|
|| (!messageNotification
|
||||||
&& notifyBy->blockStatus() == PeerData::BlockStatus::Unknown)) {
|
&& notifyBy->blockStatus() == PeerData::BlockStatus::Unknown)) {
|
||||||
return withSilent(SkipState::Unknown);
|
return withSilent(SkipState::Unknown);
|
||||||
} else if (!history->owner().notifyIsMuted(notifyBy)
|
} else if (!history->owner().notifySettings().isMuted(notifyBy)
|
||||||
&& (messageNotification || !notifyBy->isBlocked())) {
|
&& (messageNotification || !notifyBy->isBlocked())) {
|
||||||
return withSilent(SkipState::DontSkip);
|
return withSilent(SkipState::DontSkip);
|
||||||
} else {
|
} else {
|
||||||
|
@ -470,14 +471,15 @@ void System::showNext() {
|
||||||
for (auto i = _whenAlerts.begin(); i != _whenAlerts.end();) {
|
for (auto i = _whenAlerts.begin(); i != _whenAlerts.end();) {
|
||||||
while (!i->second.empty() && i->second.begin()->first <= ms) {
|
while (!i->second.empty() && i->second.begin()->first <= ms) {
|
||||||
const auto peer = i->first->peer;
|
const auto peer = i->first->peer;
|
||||||
const auto peerUnknown = peer->owner().notifyMuteUnknown(peer);
|
const auto ¬ifySettings = peer->owner().notifySettings();
|
||||||
|
const auto peerUnknown = notifySettings.muteUnknown(peer);
|
||||||
const auto peerAlert = !peerUnknown
|
const auto peerAlert = !peerUnknown
|
||||||
&& !peer->owner().notifyIsMuted(peer);
|
&& !notifySettings.isMuted(peer);
|
||||||
const auto from = i->second.begin()->second;
|
const auto from = i->second.begin()->second;
|
||||||
const auto fromUnknown = (!from
|
const auto fromUnknown = (!from
|
||||||
|| peer->owner().notifyMuteUnknown(from));
|
|| notifySettings.muteUnknown(from));
|
||||||
const auto fromAlert = !fromUnknown
|
const auto fromAlert = !fromUnknown
|
||||||
&& !peer->owner().notifyIsMuted(from);
|
&& !notifySettings.isMuted(from);
|
||||||
if (peerAlert || fromAlert) {
|
if (peerAlert || fromAlert) {
|
||||||
alert = true;
|
alert = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ void PeerMenuAddMuteSubmenuAction(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const PeerMenuCallback &addAction) {
|
const PeerMenuCallback &addAction) {
|
||||||
peer->owner().notifySettings().requestNotifySettings(peer);
|
peer->owner().notifySettings().requestNotifySettings(peer);
|
||||||
const auto isMuted = peer->owner().notifyIsMuted(peer);
|
const auto isMuted = peer->owner().notifySettings().isMuted(peer);
|
||||||
if (isMuted) {
|
if (isMuted) {
|
||||||
const auto text = tr::lng_context_unmute(tr::now)
|
const auto text = tr::lng_context_unmute(tr::now)
|
||||||
+ '\t'
|
+ '\t'
|
||||||
|
@ -146,7 +146,7 @@ void PeerMenuAddMuteSubmenuAction(
|
||||||
addAction(PeerMenuCallback::Args{
|
addAction(PeerMenuCallback::Args{
|
||||||
.text = tr::lng_context_mute(tr::now),
|
.text = tr::lng_context_mute(tr::now),
|
||||||
.handler = nullptr,
|
.handler = nullptr,
|
||||||
.icon = peer->owner().notifySoundIsNone(peer)
|
.icon = peer->owner().notifySettings().soundIsNone(peer)
|
||||||
? &st::menuIconSilent
|
? &st::menuIconSilent
|
||||||
: &st::menuIconMute,
|
: &st::menuIconMute,
|
||||||
.fillSubmenu = [=](not_null<Ui::PopupMenu*> menu) {
|
.fillSubmenu = [=](not_null<Ui::PopupMenu*> menu) {
|
||||||
|
@ -1430,14 +1430,14 @@ void PeerMenuAddMuteAction(
|
||||||
: tr::lng_context_unmute(tr::now);
|
: tr::lng_context_unmute(tr::now);
|
||||||
};
|
};
|
||||||
const auto muteAction = addAction(QString("-"), [=] {
|
const auto muteAction = addAction(QString("-"), [=] {
|
||||||
if (!peer->owner().notifyIsMuted(peer)) {
|
if (!peer->owner().notifySettings().isMuted(peer)) {
|
||||||
controller->show(
|
controller->show(
|
||||||
Box<MuteSettingsBox>(peer),
|
Box<MuteSettingsBox>(peer),
|
||||||
Ui::LayerOption::CloseOther);
|
Ui::LayerOption::CloseOther);
|
||||||
} else {
|
} else {
|
||||||
peer->owner().notifySettings().updateNotifySettings(peer, 0);
|
peer->owner().notifySettings().updateNotifySettings(peer, 0);
|
||||||
}
|
}
|
||||||
}, (peer->owner().notifyIsMuted(peer)
|
}, (peer->owner().notifySettings().isMuted(peer)
|
||||||
? &st::menuIconUnmute
|
? &st::menuIconUnmute
|
||||||
: &st::menuIconMute));
|
: &st::menuIconMute));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue