From 5a3bbfbf62bad8e6090bd658232625a209301581 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 1 Apr 2022 11:40:46 +0300 Subject: [PATCH] Renamed Data::NotifySettings to Data::PeerNotifySettings. --- Telegram/CMakeLists.txt | 4 +- Telegram/SourceFiles/data/data_peer.h | 4 +- Telegram/SourceFiles/data/data_session.cpp | 6 +-- Telegram/SourceFiles/data/data_session.h | 12 +++--- .../data_peer_notify_settings.cpp} | 42 +++++++++---------- .../data_peer_notify_settings.h} | 10 ++--- .../SourceFiles/history/history_widget.cpp | 2 +- Telegram/SourceFiles/menu/menu_mute.cpp | 2 +- 8 files changed, 41 insertions(+), 41 deletions(-) rename Telegram/SourceFiles/data/{data_notify_settings.cpp => notify/data_peer_notify_settings.cpp} (82%) rename Telegram/SourceFiles/data/{data_notify_settings.h => notify/data_peer_notify_settings.h} (87%) diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 3072e1235..a8fe64446 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -395,6 +395,8 @@ PRIVATE core/version.h countries/countries_manager.cpp countries/countries_manager.h + data/notify/data_peer_notify_settings.cpp + data/notify/data_peer_notify_settings.h data/stickers/data_stickers_set.cpp data/stickers/data_stickers_set.h data/stickers/data_stickers.cpp @@ -458,8 +460,6 @@ PRIVATE data/data_message_reactions.cpp data/data_message_reactions.h data/data_msg_id.h - data/data_notify_settings.cpp - data/data_notify_settings.h data/data_peer.cpp data/data_peer.h data/data_peer_id.cpp diff --git a/Telegram/SourceFiles/data/data_peer.h b/Telegram/SourceFiles/data/data_peer.h index 062b2f6df..0e93968e5 100644 --- a/Telegram/SourceFiles/data/data_peer.h +++ b/Telegram/SourceFiles/data/data_peer.h @@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_types.h" #include "data/data_flags.h" -#include "data/data_notify_settings.h" +#include "data/notify/data_peer_notify_settings.h" #include "data/data_cloud_file.h" class PeerData; @@ -440,7 +440,7 @@ private: mutable std::unique_ptr _userpicEmpty; Ui::Text::String _nameText; - Data::NotifySettings _notify; + Data::PeerNotifySettings _notify; ClickHandlerPtr _openLink; base::flat_set _nameWords; // for filtering diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index dd031c099..9e58f8b33 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -2222,7 +2222,7 @@ Session::SentData Session::messageSentData(uint64 randomId) const { return (i != end(_sentMessagesData)) ? i->second : SentData(); } -NotifySettings &Session::defaultNotifySettings( +PeerNotifySettings &Session::defaultNotifySettings( not_null peer) { return peer->isUser() ? _defaultUserNotifySettings @@ -2231,7 +2231,7 @@ NotifySettings &Session::defaultNotifySettings( : _defaultBroadcastNotifySettings; } -const NotifySettings &Session::defaultNotifySettings( +const PeerNotifySettings &Session::defaultNotifySettings( not_null peer) const { return peer->isUser() ? _defaultUserNotifySettings @@ -3893,7 +3893,7 @@ void Session::applyNotifySetting( const MTPPeerNotifySettings &settings) { const auto goodForUpdate = [&]( not_null peer, - const NotifySettings &settings) { + const PeerNotifySettings &settings) { return !peer->notifySettingsUnknown() && ((!peer->notifyMuteUntil() && settings.muteUntil()) || (!peer->notifySilentPosts() && settings.silentPosts()) diff --git a/Telegram/SourceFiles/data/data_session.h b/Telegram/SourceFiles/data/data_session.h index f6cd7a830..bf71f425e 100644 --- a/Telegram/SourceFiles/data/data_session.h +++ b/Telegram/SourceFiles/data/data_session.h @@ -13,7 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "dialogs/dialogs_main_list.h" #include "data/data_groups.h" #include "data/data_cloud_file.h" -#include "data/data_notify_settings.h" +#include "data/notify/data_peer_notify_settings.h" #include "history/history_location_manager.h" #include "base/timer.h" #include "base/flags.h" @@ -822,8 +822,8 @@ private: void setPinnedFromDialog(const Dialogs::Key &key, bool pinned); - NotifySettings &defaultNotifySettings(not_null peer); - const NotifySettings &defaultNotifySettings( + PeerNotifySettings &defaultNotifySettings(not_null peer); + const PeerNotifySettings &defaultNotifySettings( not_null peer) const; void unmuteByFinished(); void unmuteByFinishedDelayed(crl::time delay); @@ -976,9 +976,9 @@ private: History *_topPromoted = nullptr; - NotifySettings _defaultUserNotifySettings; - NotifySettings _defaultChatNotifySettings; - NotifySettings _defaultBroadcastNotifySettings; + PeerNotifySettings _defaultUserNotifySettings; + PeerNotifySettings _defaultChatNotifySettings; + PeerNotifySettings _defaultBroadcastNotifySettings; rpl::event_stream<> _defaultUserNotifyUpdates; rpl::event_stream<> _defaultChatNotifyUpdates; rpl::event_stream<> _defaultBroadcastNotifyUpdates; diff --git a/Telegram/SourceFiles/data/data_notify_settings.cpp b/Telegram/SourceFiles/data/notify/data_peer_notify_settings.cpp similarity index 82% rename from Telegram/SourceFiles/data/data_notify_settings.cpp rename to Telegram/SourceFiles/data/notify/data_peer_notify_settings.cpp index 1b7c6ee6a..79555109a 100644 --- a/Telegram/SourceFiles/data/data_notify_settings.cpp +++ b/Telegram/SourceFiles/data/notify/data_peer_notify_settings.cpp @@ -5,7 +5,7 @@ the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ -#include "data/data_notify_settings.h" +#include "data/notify/data_peer_notify_settings.h" #include "base/unixtime.h" @@ -53,9 +53,9 @@ namespace { } // namespace -class NotifySettingsValue { +class NotifyPeerSettingsValue { public: - NotifySettingsValue(const MTPDpeerNotifySettings &data); + NotifyPeerSettingsValue(const MTPDpeerNotifySettings &data); bool change(const MTPDpeerNotifySettings &data); bool change( @@ -82,12 +82,12 @@ private: }; -NotifySettingsValue::NotifySettingsValue( +NotifyPeerSettingsValue::NotifyPeerSettingsValue( const MTPDpeerNotifySettings &data) { change(data); } -bool NotifySettingsValue::change(const MTPDpeerNotifySettings &data) { +bool NotifyPeerSettingsValue::change(const MTPDpeerNotifySettings &data) { const auto mute = data.vmute_until(); const auto sound = data.vother_sound(); const auto showPreviews = data.vshow_previews(); @@ -101,7 +101,7 @@ bool NotifySettingsValue::change(const MTPDpeerNotifySettings &data) { silent ? std::make_optional(mtpIsTrue(*silent)) : std::nullopt); } -bool NotifySettingsValue::change( +bool NotifyPeerSettingsValue::change( std::optional muteForSeconds, std::optional silentPosts, std::optional sound) { @@ -127,7 +127,7 @@ bool NotifySettingsValue::change( newSilentPosts); } -bool NotifySettingsValue::change( +bool NotifyPeerSettingsValue::change( std::optional mute, std::optional sound, std::optional showPreviews, @@ -145,19 +145,19 @@ bool NotifySettingsValue::change( return true; } -std::optional NotifySettingsValue::muteUntil() const { +std::optional NotifyPeerSettingsValue::muteUntil() const { return _mute; } -std::optional NotifySettingsValue::silentPosts() const { +std::optional NotifyPeerSettingsValue::silentPosts() const { return _silent; } -std::optional NotifySettingsValue::sound() const { +std::optional NotifyPeerSettingsValue::sound() const { return _sound; } -MTPinputPeerNotifySettings NotifySettingsValue::serialize() const { +MTPinputPeerNotifySettings NotifyPeerSettingsValue::serialize() const { using Flag = MTPDinputPeerNotifySettings::Flag; const auto flag = [](auto &&optional, Flag flag) { return optional.has_value() ? flag : Flag(0); @@ -173,9 +173,9 @@ MTPinputPeerNotifySettings NotifySettingsValue::serialize() const { SerializeSound(_sound)); } -NotifySettings::NotifySettings() = default; +PeerNotifySettings::PeerNotifySettings() = default; -bool NotifySettings::change(const MTPPeerNotifySettings &settings) { +bool PeerNotifySettings::change(const MTPPeerNotifySettings &settings) { Expects(settings.type() == mtpc_peerNotifySettings); auto &data = settings.c_peerNotifySettings(); @@ -192,11 +192,11 @@ bool NotifySettings::change(const MTPPeerNotifySettings &settings) { return _value->change(data); } _known = true; - _value = std::make_unique(data); + _value = std::make_unique(data); return true; } -bool NotifySettings::change( +bool PeerNotifySettings::change( std::optional muteForSeconds, std::optional silentPosts, std::optional soundIsNone) { @@ -225,34 +225,34 @@ bool NotifySettings::change( SerializeSound(notificationSound))); } -std::optional NotifySettings::muteUntil() const { +std::optional PeerNotifySettings::muteUntil() const { return _value ? _value->muteUntil() : std::nullopt; } -bool NotifySettings::settingsUnknown() const { +bool PeerNotifySettings::settingsUnknown() const { return !_known; } -std::optional NotifySettings::silentPosts() const { +std::optional PeerNotifySettings::silentPosts() const { return _value ? _value->silentPosts() : std::nullopt; } -std::optional NotifySettings::soundIsNone() const { +std::optional PeerNotifySettings::soundIsNone() const { return (!_value || !_value->sound()) ? std::nullopt : std::make_optional(_value->sound()->none); } -MTPinputPeerNotifySettings NotifySettings::serialize() const { +MTPinputPeerNotifySettings PeerNotifySettings::serialize() const { return _value ? _value->serialize() : DefaultSettings(); } -NotifySettings::~NotifySettings() = default; +PeerNotifySettings::~PeerNotifySettings() = default; } // namespace Data diff --git a/Telegram/SourceFiles/data/data_notify_settings.h b/Telegram/SourceFiles/data/notify/data_peer_notify_settings.h similarity index 87% rename from Telegram/SourceFiles/data/data_notify_settings.h rename to Telegram/SourceFiles/data/notify/data_peer_notify_settings.h index f868ce4fe..dc6d43aff 100644 --- a/Telegram/SourceFiles/data/data_notify_settings.h +++ b/Telegram/SourceFiles/data/notify/data_peer_notify_settings.h @@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Data { -class NotifySettingsValue; +class NotifyPeerSettingsValue; struct NotifySound { QString title; @@ -25,9 +25,9 @@ inline bool operator==(const NotifySound &a, const NotifySound &b) { && (a.data == b.data); } -class NotifySettings { +class PeerNotifySettings { public: - NotifySettings(); + PeerNotifySettings(); static constexpr auto kDefaultMutePeriod = 86400 * 365; @@ -43,11 +43,11 @@ public: std::optional soundIsNone() const; MTPinputPeerNotifySettings serialize() const; - ~NotifySettings(); + ~PeerNotifySettings(); private: bool _known = false; - std::unique_ptr _value; + std::unique_ptr _value; }; diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index ee02ef7b8..2dd0142ce 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -3849,7 +3849,7 @@ void HistoryWidget::joinChannel() { void HistoryWidget::toggleMuteUnmute() { const auto muteForSeconds = _history->mute() ? 0 - : Data::NotifySettings::kDefaultMutePeriod; + : Data::PeerNotifySettings::kDefaultMutePeriod; session().data().updateNotifySettings(_peer, muteForSeconds); } diff --git a/Telegram/SourceFiles/menu/menu_mute.cpp b/Telegram/SourceFiles/menu/menu_mute.cpp index cc21e1550..617a5eefd 100644 --- a/Telegram/SourceFiles/menu/menu_mute.cpp +++ b/Telegram/SourceFiles/menu/menu_mute.cpp @@ -79,7 +79,7 @@ MuteItem::MuteItem( setClickedCallback([=] { peer->owner().updateNotifySettings( peer, - _isMuted ? 0 : Data::NotifySettings::kDefaultMutePeriod); + _isMuted ? 0 : Data::PeerNotifySettings::kDefaultMutePeriod); }); }