Renamed Data::NotifySettings to Data::PeerNotifySettings.

This commit is contained in:
23rd 2022-04-01 11:40:46 +03:00 committed by John Preston
parent 70d1a1e376
commit 5a3bbfbf62
8 changed files with 41 additions and 41 deletions

View File

@ -395,6 +395,8 @@ PRIVATE
core/version.h core/version.h
countries/countries_manager.cpp countries/countries_manager.cpp
countries/countries_manager.h 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.cpp
data/stickers/data_stickers_set.h data/stickers/data_stickers_set.h
data/stickers/data_stickers.cpp data/stickers/data_stickers.cpp
@ -458,8 +460,6 @@ PRIVATE
data/data_message_reactions.cpp data/data_message_reactions.cpp
data/data_message_reactions.h data/data_message_reactions.h
data/data_msg_id.h data/data_msg_id.h
data/data_notify_settings.cpp
data/data_notify_settings.h
data/data_peer.cpp data/data_peer.cpp
data/data_peer.h data/data_peer.h
data/data_peer_id.cpp data/data_peer_id.cpp

View File

@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_types.h" #include "data/data_types.h"
#include "data/data_flags.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" #include "data/data_cloud_file.h"
class PeerData; class PeerData;
@ -440,7 +440,7 @@ private:
mutable std::unique_ptr<Ui::EmptyUserpic> _userpicEmpty; mutable std::unique_ptr<Ui::EmptyUserpic> _userpicEmpty;
Ui::Text::String _nameText; Ui::Text::String _nameText;
Data::NotifySettings _notify; Data::PeerNotifySettings _notify;
ClickHandlerPtr _openLink; ClickHandlerPtr _openLink;
base::flat_set<QString> _nameWords; // for filtering base::flat_set<QString> _nameWords; // for filtering

View File

@ -2222,7 +2222,7 @@ Session::SentData Session::messageSentData(uint64 randomId) const {
return (i != end(_sentMessagesData)) ? i->second : SentData(); return (i != end(_sentMessagesData)) ? i->second : SentData();
} }
NotifySettings &Session::defaultNotifySettings( PeerNotifySettings &Session::defaultNotifySettings(
not_null<const PeerData*> peer) { not_null<const PeerData*> peer) {
return peer->isUser() return peer->isUser()
? _defaultUserNotifySettings ? _defaultUserNotifySettings
@ -2231,7 +2231,7 @@ NotifySettings &Session::defaultNotifySettings(
: _defaultBroadcastNotifySettings; : _defaultBroadcastNotifySettings;
} }
const NotifySettings &Session::defaultNotifySettings( const PeerNotifySettings &Session::defaultNotifySettings(
not_null<const PeerData*> peer) const { not_null<const PeerData*> peer) const {
return peer->isUser() return peer->isUser()
? _defaultUserNotifySettings ? _defaultUserNotifySettings
@ -3893,7 +3893,7 @@ void Session::applyNotifySetting(
const MTPPeerNotifySettings &settings) { const MTPPeerNotifySettings &settings) {
const auto goodForUpdate = [&]( const auto goodForUpdate = [&](
not_null<const PeerData*> peer, not_null<const PeerData*> peer,
const NotifySettings &settings) { const PeerNotifySettings &settings) {
return !peer->notifySettingsUnknown() return !peer->notifySettingsUnknown()
&& ((!peer->notifyMuteUntil() && settings.muteUntil()) && ((!peer->notifyMuteUntil() && settings.muteUntil())
|| (!peer->notifySilentPosts() && settings.silentPosts()) || (!peer->notifySilentPosts() && settings.silentPosts())

View File

@ -13,7 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "dialogs/dialogs_main_list.h" #include "dialogs/dialogs_main_list.h"
#include "data/data_groups.h" #include "data/data_groups.h"
#include "data/data_cloud_file.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 "history/history_location_manager.h"
#include "base/timer.h" #include "base/timer.h"
#include "base/flags.h" #include "base/flags.h"
@ -822,8 +822,8 @@ private:
void setPinnedFromDialog(const Dialogs::Key &key, bool pinned); void setPinnedFromDialog(const Dialogs::Key &key, bool pinned);
NotifySettings &defaultNotifySettings(not_null<const PeerData*> peer); PeerNotifySettings &defaultNotifySettings(not_null<const PeerData*> peer);
const NotifySettings &defaultNotifySettings( const PeerNotifySettings &defaultNotifySettings(
not_null<const PeerData*> peer) const; not_null<const PeerData*> peer) const;
void unmuteByFinished(); void unmuteByFinished();
void unmuteByFinishedDelayed(crl::time delay); void unmuteByFinishedDelayed(crl::time delay);
@ -976,9 +976,9 @@ private:
History *_topPromoted = nullptr; History *_topPromoted = nullptr;
NotifySettings _defaultUserNotifySettings; PeerNotifySettings _defaultUserNotifySettings;
NotifySettings _defaultChatNotifySettings; PeerNotifySettings _defaultChatNotifySettings;
NotifySettings _defaultBroadcastNotifySettings; PeerNotifySettings _defaultBroadcastNotifySettings;
rpl::event_stream<> _defaultUserNotifyUpdates; rpl::event_stream<> _defaultUserNotifyUpdates;
rpl::event_stream<> _defaultChatNotifyUpdates; rpl::event_stream<> _defaultChatNotifyUpdates;
rpl::event_stream<> _defaultBroadcastNotifyUpdates; rpl::event_stream<> _defaultBroadcastNotifyUpdates;

View File

@ -5,7 +5,7 @@ the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link: For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL 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" #include "base/unixtime.h"
@ -53,9 +53,9 @@ namespace {
} // namespace } // namespace
class NotifySettingsValue { class NotifyPeerSettingsValue {
public: public:
NotifySettingsValue(const MTPDpeerNotifySettings &data); NotifyPeerSettingsValue(const MTPDpeerNotifySettings &data);
bool change(const MTPDpeerNotifySettings &data); bool change(const MTPDpeerNotifySettings &data);
bool change( bool change(
@ -82,12 +82,12 @@ private:
}; };
NotifySettingsValue::NotifySettingsValue( NotifyPeerSettingsValue::NotifyPeerSettingsValue(
const MTPDpeerNotifySettings &data) { const MTPDpeerNotifySettings &data) {
change(data); change(data);
} }
bool NotifySettingsValue::change(const MTPDpeerNotifySettings &data) { bool NotifyPeerSettingsValue::change(const MTPDpeerNotifySettings &data) {
const auto mute = data.vmute_until(); const auto mute = data.vmute_until();
const auto sound = data.vother_sound(); const auto sound = data.vother_sound();
const auto showPreviews = data.vshow_previews(); const auto showPreviews = data.vshow_previews();
@ -101,7 +101,7 @@ bool NotifySettingsValue::change(const MTPDpeerNotifySettings &data) {
silent ? std::make_optional(mtpIsTrue(*silent)) : std::nullopt); silent ? std::make_optional(mtpIsTrue(*silent)) : std::nullopt);
} }
bool NotifySettingsValue::change( bool NotifyPeerSettingsValue::change(
std::optional<int> muteForSeconds, std::optional<int> muteForSeconds,
std::optional<bool> silentPosts, std::optional<bool> silentPosts,
std::optional<NotifySound> sound) { std::optional<NotifySound> sound) {
@ -127,7 +127,7 @@ bool NotifySettingsValue::change(
newSilentPosts); newSilentPosts);
} }
bool NotifySettingsValue::change( bool NotifyPeerSettingsValue::change(
std::optional<int> mute, std::optional<int> mute,
std::optional<NotifySound> sound, std::optional<NotifySound> sound,
std::optional<bool> showPreviews, std::optional<bool> showPreviews,
@ -145,19 +145,19 @@ bool NotifySettingsValue::change(
return true; return true;
} }
std::optional<TimeId> NotifySettingsValue::muteUntil() const { std::optional<TimeId> NotifyPeerSettingsValue::muteUntil() const {
return _mute; return _mute;
} }
std::optional<bool> NotifySettingsValue::silentPosts() const { std::optional<bool> NotifyPeerSettingsValue::silentPosts() const {
return _silent; return _silent;
} }
std::optional<NotifySound> NotifySettingsValue::sound() const { std::optional<NotifySound> NotifyPeerSettingsValue::sound() const {
return _sound; return _sound;
} }
MTPinputPeerNotifySettings NotifySettingsValue::serialize() const { MTPinputPeerNotifySettings NotifyPeerSettingsValue::serialize() const {
using Flag = MTPDinputPeerNotifySettings::Flag; using Flag = MTPDinputPeerNotifySettings::Flag;
const auto flag = [](auto &&optional, Flag flag) { const auto flag = [](auto &&optional, Flag flag) {
return optional.has_value() ? flag : Flag(0); return optional.has_value() ? flag : Flag(0);
@ -173,9 +173,9 @@ MTPinputPeerNotifySettings NotifySettingsValue::serialize() const {
SerializeSound(_sound)); 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); Expects(settings.type() == mtpc_peerNotifySettings);
auto &data = settings.c_peerNotifySettings(); auto &data = settings.c_peerNotifySettings();
@ -192,11 +192,11 @@ bool NotifySettings::change(const MTPPeerNotifySettings &settings) {
return _value->change(data); return _value->change(data);
} }
_known = true; _known = true;
_value = std::make_unique<NotifySettingsValue>(data); _value = std::make_unique<NotifyPeerSettingsValue>(data);
return true; return true;
} }
bool NotifySettings::change( bool PeerNotifySettings::change(
std::optional<int> muteForSeconds, std::optional<int> muteForSeconds,
std::optional<bool> silentPosts, std::optional<bool> silentPosts,
std::optional<bool> soundIsNone) { std::optional<bool> soundIsNone) {
@ -225,34 +225,34 @@ bool NotifySettings::change(
SerializeSound(notificationSound))); SerializeSound(notificationSound)));
} }
std::optional<TimeId> NotifySettings::muteUntil() const { std::optional<TimeId> PeerNotifySettings::muteUntil() const {
return _value return _value
? _value->muteUntil() ? _value->muteUntil()
: std::nullopt; : std::nullopt;
} }
bool NotifySettings::settingsUnknown() const { bool PeerNotifySettings::settingsUnknown() const {
return !_known; return !_known;
} }
std::optional<bool> NotifySettings::silentPosts() const { std::optional<bool> PeerNotifySettings::silentPosts() const {
return _value return _value
? _value->silentPosts() ? _value->silentPosts()
: std::nullopt; : std::nullopt;
} }
std::optional<bool> NotifySettings::soundIsNone() const { std::optional<bool> PeerNotifySettings::soundIsNone() const {
return (!_value || !_value->sound()) return (!_value || !_value->sound())
? std::nullopt ? std::nullopt
: std::make_optional(_value->sound()->none); : std::make_optional(_value->sound()->none);
} }
MTPinputPeerNotifySettings NotifySettings::serialize() const { MTPinputPeerNotifySettings PeerNotifySettings::serialize() const {
return _value return _value
? _value->serialize() ? _value->serialize()
: DefaultSettings(); : DefaultSettings();
} }
NotifySettings::~NotifySettings() = default; PeerNotifySettings::~PeerNotifySettings() = default;
} // namespace Data } // namespace Data

View File

@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Data { namespace Data {
class NotifySettingsValue; class NotifyPeerSettingsValue;
struct NotifySound { struct NotifySound {
QString title; QString title;
@ -25,9 +25,9 @@ inline bool operator==(const NotifySound &a, const NotifySound &b) {
&& (a.data == b.data); && (a.data == b.data);
} }
class NotifySettings { class PeerNotifySettings {
public: public:
NotifySettings(); PeerNotifySettings();
static constexpr auto kDefaultMutePeriod = 86400 * 365; static constexpr auto kDefaultMutePeriod = 86400 * 365;
@ -43,11 +43,11 @@ public:
std::optional<bool> soundIsNone() const; std::optional<bool> soundIsNone() const;
MTPinputPeerNotifySettings serialize() const; MTPinputPeerNotifySettings serialize() const;
~NotifySettings(); ~PeerNotifySettings();
private: private:
bool _known = false; bool _known = false;
std::unique_ptr<NotifySettingsValue> _value; std::unique_ptr<NotifyPeerSettingsValue> _value;
}; };

View File

@ -3849,7 +3849,7 @@ void HistoryWidget::joinChannel() {
void HistoryWidget::toggleMuteUnmute() { void HistoryWidget::toggleMuteUnmute() {
const auto muteForSeconds = _history->mute() const auto muteForSeconds = _history->mute()
? 0 ? 0
: Data::NotifySettings::kDefaultMutePeriod; : Data::PeerNotifySettings::kDefaultMutePeriod;
session().data().updateNotifySettings(_peer, muteForSeconds); session().data().updateNotifySettings(_peer, muteForSeconds);
} }

View File

@ -79,7 +79,7 @@ MuteItem::MuteItem(
setClickedCallback([=] { setClickedCallback([=] {
peer->owner().updateNotifySettings( peer->owner().updateNotifySettings(
peer, peer,
_isMuted ? 0 : Data::NotifySettings::kDefaultMutePeriod); _isMuted ? 0 : Data::PeerNotifySettings::kDefaultMutePeriod);
}); });
} }