mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-05 09:05:14 +00:00
Update API scheme on layer 160.
This commit is contained in:
@@ -174,8 +174,13 @@ void NotifySettings::update(
|
||||
not_null<Data::Thread*> thread,
|
||||
Data::MuteValue muteForSeconds,
|
||||
std::optional<bool> silentPosts,
|
||||
std::optional<NotifySound> sound) {
|
||||
if (thread->notify().change(muteForSeconds, silentPosts, sound)) {
|
||||
std::optional<NotifySound> sound,
|
||||
std::optional<bool> storiesMuted) {
|
||||
if (thread->notify().change(
|
||||
muteForSeconds,
|
||||
silentPosts,
|
||||
sound,
|
||||
storiesMuted)) {
|
||||
updateLocal(thread);
|
||||
thread->session().api().updateNotifySettingsDelayed(thread);
|
||||
}
|
||||
@@ -189,7 +194,8 @@ void NotifySettings::resetToDefault(not_null<Data::Thread*> thread) {
|
||||
MTPint(),
|
||||
MTPNotificationSound(),
|
||||
MTPNotificationSound(),
|
||||
MTPNotificationSound());
|
||||
MTPNotificationSound(),
|
||||
MTPBool());
|
||||
if (thread->notify().change(empty)) {
|
||||
updateLocal(thread);
|
||||
thread->session().api().updateNotifySettingsDelayed(thread);
|
||||
@@ -200,8 +206,13 @@ void NotifySettings::update(
|
||||
not_null<PeerData*> peer,
|
||||
Data::MuteValue muteForSeconds,
|
||||
std::optional<bool> silentPosts,
|
||||
std::optional<NotifySound> sound) {
|
||||
if (peer->notify().change(muteForSeconds, silentPosts, sound)) {
|
||||
std::optional<NotifySound> sound,
|
||||
std::optional<bool> storiesMuted) {
|
||||
if (peer->notify().change(
|
||||
muteForSeconds,
|
||||
silentPosts,
|
||||
sound,
|
||||
storiesMuted)) {
|
||||
updateLocal(peer);
|
||||
peer->session().api().updateNotifySettingsDelayed(peer);
|
||||
}
|
||||
@@ -215,7 +226,8 @@ void NotifySettings::resetToDefault(not_null<PeerData*> peer) {
|
||||
MTPint(),
|
||||
MTPNotificationSound(),
|
||||
MTPNotificationSound(),
|
||||
MTPNotificationSound());
|
||||
MTPNotificationSound(),
|
||||
MTPBool());
|
||||
if (peer->notify().change(empty)) {
|
||||
updateLocal(peer);
|
||||
peer->session().api().updateNotifySettingsDelayed(peer);
|
||||
@@ -262,9 +274,10 @@ void NotifySettings::defaultUpdate(
|
||||
DefaultNotify type,
|
||||
Data::MuteValue muteForSeconds,
|
||||
std::optional<bool> silentPosts,
|
||||
std::optional<NotifySound> sound) {
|
||||
std::optional<NotifySound> sound,
|
||||
std::optional<bool> storiesMuted) {
|
||||
auto &settings = defaultValue(type).settings;
|
||||
if (settings.change(muteForSeconds, silentPosts, sound)) {
|
||||
if (settings.change(muteForSeconds, silentPosts, sound, storiesMuted)) {
|
||||
updateLocal(type);
|
||||
_owner->session().api().updateNotifySettingsDelayed(type);
|
||||
}
|
||||
|
@@ -57,13 +57,15 @@ public:
|
||||
not_null<Data::Thread*> thread,
|
||||
Data::MuteValue muteForSeconds,
|
||||
std::optional<bool> silentPosts = std::nullopt,
|
||||
std::optional<NotifySound> sound = std::nullopt);
|
||||
std::optional<NotifySound> sound = std::nullopt,
|
||||
std::optional<bool> storiesMuted = std::nullopt);
|
||||
void resetToDefault(not_null<Data::Thread*> thread);
|
||||
void update(
|
||||
not_null<PeerData*> peer,
|
||||
Data::MuteValue muteForSeconds,
|
||||
std::optional<bool> silentPosts = std::nullopt,
|
||||
std::optional<NotifySound> sound = std::nullopt);
|
||||
std::optional<NotifySound> sound = std::nullopt,
|
||||
std::optional<bool> storiesMuted = std::nullopt);
|
||||
void resetToDefault(not_null<PeerData*> peer);
|
||||
|
||||
void forumParentMuteUpdated(not_null<Data::Forum*> forum);
|
||||
@@ -84,7 +86,8 @@ public:
|
||||
DefaultNotify type,
|
||||
Data::MuteValue muteForSeconds,
|
||||
std::optional<bool> silentPosts = std::nullopt,
|
||||
std::optional<NotifySound> sound = std::nullopt);
|
||||
std::optional<NotifySound> sound = std::nullopt,
|
||||
std::optional<bool> storiesMuted = std::nullopt);
|
||||
|
||||
[[nodiscard]] bool isMuted(not_null<const Data::Thread*> thread) const;
|
||||
[[nodiscard]] NotifySound sound(
|
||||
|
@@ -18,7 +18,8 @@ namespace {
|
||||
MTPBool(),
|
||||
MTPBool(),
|
||||
MTPint(),
|
||||
MTPNotificationSound());
|
||||
MTPNotificationSound(),
|
||||
MTPBool());
|
||||
}
|
||||
|
||||
[[nodiscard]] NotifySound ParseSound(const MTPNotificationSound &sound) {
|
||||
@@ -73,7 +74,8 @@ public:
|
||||
bool change(
|
||||
MuteValue muteForSeconds,
|
||||
std::optional<bool> silentPosts,
|
||||
std::optional<NotifySound> sound);
|
||||
std::optional<NotifySound> sound,
|
||||
std::optional<bool> storiesMuted);
|
||||
|
||||
std::optional<TimeId> muteUntil() const;
|
||||
std::optional<bool> silentPosts() const;
|
||||
@@ -85,12 +87,14 @@ private:
|
||||
std::optional<int> mute,
|
||||
std::optional<NotifySound> sound,
|
||||
std::optional<bool> showPreviews,
|
||||
std::optional<bool> silentPosts);
|
||||
std::optional<bool> silentPosts,
|
||||
std::optional<bool> storiesMuted);
|
||||
|
||||
std::optional<TimeId> _mute;
|
||||
std::optional<NotifySound> _sound;
|
||||
std::optional<bool> _silent;
|
||||
std::optional<bool> _showPreviews;
|
||||
std::optional<bool> _storiesMuted;
|
||||
|
||||
};
|
||||
|
||||
@@ -104,19 +108,24 @@ bool NotifyPeerSettingsValue::change(const MTPDpeerNotifySettings &data) {
|
||||
const auto sound = data.vother_sound();
|
||||
const auto showPreviews = data.vshow_previews();
|
||||
const auto silent = data.vsilent();
|
||||
const auto storiesMuted = data.vstories_muted();
|
||||
return change(
|
||||
mute ? std::make_optional(mute->v) : std::nullopt,
|
||||
sound ? std::make_optional(ParseSound(*sound)) : std::nullopt,
|
||||
(showPreviews
|
||||
? std::make_optional(mtpIsTrue(*showPreviews))
|
||||
: std::nullopt),
|
||||
silent ? std::make_optional(mtpIsTrue(*silent)) : std::nullopt);
|
||||
silent ? std::make_optional(mtpIsTrue(*silent)) : std::nullopt,
|
||||
(storiesMuted
|
||||
? std::make_optional(mtpIsTrue(*storiesMuted))
|
||||
: std::nullopt));
|
||||
}
|
||||
|
||||
bool NotifyPeerSettingsValue::change(
|
||||
MuteValue muteForSeconds,
|
||||
std::optional<bool> silentPosts,
|
||||
std::optional<NotifySound> sound) {
|
||||
std::optional<NotifySound> sound,
|
||||
std::optional<bool> storiesMuted) {
|
||||
const auto newMute = muteForSeconds
|
||||
? base::make_optional(muteForSeconds.until())
|
||||
: _mute;
|
||||
@@ -126,28 +135,35 @@ bool NotifyPeerSettingsValue::change(
|
||||
const auto newSound = sound
|
||||
? base::make_optional(*sound)
|
||||
: _sound;
|
||||
const auto newStoriesMuted = storiesMuted
|
||||
? base::make_optional(*storiesMuted)
|
||||
: _storiesMuted;
|
||||
return change(
|
||||
newMute,
|
||||
newSound,
|
||||
_showPreviews,
|
||||
newSilentPosts);
|
||||
newSilentPosts,
|
||||
newStoriesMuted);
|
||||
}
|
||||
|
||||
bool NotifyPeerSettingsValue::change(
|
||||
std::optional<int> mute,
|
||||
std::optional<NotifySound> sound,
|
||||
std::optional<bool> showPreviews,
|
||||
std::optional<bool> silentPosts) {
|
||||
std::optional<bool> silentPosts,
|
||||
std::optional<bool> storiesMuted) {
|
||||
if (_mute == mute
|
||||
&& _sound == sound
|
||||
&& _showPreviews == showPreviews
|
||||
&& _silent == silentPosts) {
|
||||
&& _silent == silentPosts
|
||||
&& _storiesMuted == storiesMuted) {
|
||||
return false;
|
||||
}
|
||||
_mute = mute;
|
||||
_sound = sound;
|
||||
_showPreviews = showPreviews;
|
||||
_silent = silentPosts;
|
||||
_storiesMuted = storiesMuted;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -172,11 +188,13 @@ MTPinputPeerNotifySettings NotifyPeerSettingsValue::serialize() const {
|
||||
MTP_flags(flag(_mute, Flag::f_mute_until)
|
||||
| flag(_sound, Flag::f_sound)
|
||||
| flag(_silent, Flag::f_silent)
|
||||
| flag(_showPreviews, Flag::f_show_previews)),
|
||||
MTP_bool(_showPreviews ? *_showPreviews : true),
|
||||
MTP_bool(_silent ? *_silent : false),
|
||||
MTP_int(_mute ? *_mute : false),
|
||||
SerializeSound(_sound));
|
||||
| flag(_showPreviews, Flag::f_show_previews)
|
||||
| flag(_storiesMuted, Flag::f_stories_muted)),
|
||||
MTP_bool(_showPreviews.value_or(true)),
|
||||
MTP_bool(_silent.value_or(false)),
|
||||
MTP_int(_mute.value_or(false)),
|
||||
SerializeSound(_sound),
|
||||
MTP_bool(_storiesMuted.value_or(false)));
|
||||
}
|
||||
|
||||
PeerNotifySettings::PeerNotifySettings() = default;
|
||||
@@ -203,16 +221,22 @@ bool PeerNotifySettings::change(const MTPPeerNotifySettings &settings) {
|
||||
bool PeerNotifySettings::change(
|
||||
MuteValue muteForSeconds,
|
||||
std::optional<bool> silentPosts,
|
||||
std::optional<NotifySound> sound) {
|
||||
if (!muteForSeconds && !silentPosts && !sound) {
|
||||
std::optional<NotifySound> sound,
|
||||
std::optional<bool> storiesMuted) {
|
||||
if (!muteForSeconds && !silentPosts && !sound && !storiesMuted) {
|
||||
return false;
|
||||
} else if (_value) {
|
||||
return _value->change(muteForSeconds, silentPosts, sound);
|
||||
return _value->change(
|
||||
muteForSeconds,
|
||||
silentPosts,
|
||||
sound,
|
||||
storiesMuted);
|
||||
}
|
||||
using Flag = MTPDpeerNotifySettings::Flag;
|
||||
const auto flags = (muteForSeconds ? Flag::f_mute_until : Flag(0))
|
||||
| (silentPosts ? Flag::f_silent : Flag(0))
|
||||
| (sound ? Flag::f_other_sound : Flag(0));
|
||||
| (sound ? Flag::f_other_sound : Flag(0))
|
||||
| (storiesMuted ? Flag::f_stories_muted : Flag(0));
|
||||
return change(MTP_peerNotifySettings(
|
||||
MTP_flags(flags),
|
||||
MTPBool(),
|
||||
@@ -220,7 +244,8 @@ bool PeerNotifySettings::change(
|
||||
MTP_int(muteForSeconds.until()),
|
||||
MTPNotificationSound(),
|
||||
MTPNotificationSound(),
|
||||
SerializeSound(sound)));
|
||||
SerializeSound(sound),
|
||||
storiesMuted ? MTP_bool(*storiesMuted) : MTPBool()));
|
||||
}
|
||||
|
||||
std::optional<TimeId> PeerNotifySettings::muteUntil() const {
|
||||
|
@@ -44,7 +44,8 @@ public:
|
||||
bool change(
|
||||
MuteValue muteForSeconds,
|
||||
std::optional<bool> silentPosts,
|
||||
std::optional<NotifySound> sound);
|
||||
std::optional<NotifySound> sound,
|
||||
std::optional<bool> storiesMuted);
|
||||
|
||||
bool settingsUnknown() const;
|
||||
std::optional<TimeId> muteUntil() const;
|
||||
|
Reference in New Issue
Block a user