mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 22:27:20 +02:00
Update API scheme on layer 160.
This commit is contained in:
parent
af5228771c
commit
bafb4f91b4
8 changed files with 82 additions and 35 deletions
|
@ -3790,6 +3790,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_userpic_builder_color_subtitle" = "Choose background";
|
||||
"lng_userpic_builder_emoji_subtitle" = "Choose sticker or emoji";
|
||||
|
||||
"lng_stories_my_name" = "My Story";
|
||||
"lng_stories_hide_to_contacts" = "Archive";
|
||||
"lng_stories_show_in_chats" = "Unarchive";
|
||||
"lng_stories_row_count#one" = "{count} Story";
|
||||
|
|
|
@ -1804,7 +1804,8 @@ void ApiWrap::requestNotifySettings(const MTPInputNotifyPeer &peer) {
|
|||
MTPint(),
|
||||
MTPNotificationSound(),
|
||||
MTPNotificationSound(),
|
||||
MTPNotificationSound()));
|
||||
MTPNotificationSound(),
|
||||
MTPBool()));
|
||||
_notifySettingRequests.erase(key);
|
||||
}).send();
|
||||
_notifySettingRequests.emplace(key, requestId);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_user.h"
|
||||
#include "dialogs/ui/dialogs_stories_list.h"
|
||||
#include "main/main_session.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/painter.h"
|
||||
|
||||
namespace Dialogs::Stories {
|
||||
|
@ -144,7 +145,9 @@ Content State::next() {
|
|||
}
|
||||
result.users.push_back({
|
||||
.id = uint64(user->id.value),
|
||||
.name = user->shortName(),
|
||||
.name = (user->isSelf()
|
||||
? tr::lng_stories_my_name(tr::now)
|
||||
: user->shortName()),
|
||||
.userpic = std::move(userpic),
|
||||
.unread = info.unread,
|
||||
.hidden = info.hidden,
|
||||
|
|
|
@ -129,7 +129,7 @@ messageMediaInvoice#f6a548d3 flags:# shipping_address_requested:flags.1?true tes
|
|||
messageMediaGeoLive#b940c666 flags:# geo:GeoPoint heading:flags.0?int period:int proximity_notification_radius:flags.1?int = MessageMedia;
|
||||
messageMediaPoll#4bd6e798 poll:Poll results:PollResults = MessageMedia;
|
||||
messageMediaDice#3f7ee58b value:int emoticon:string = MessageMedia;
|
||||
messageMediaStory#c79aee11 user_id:long id:int = MessageMedia;
|
||||
messageMediaStory#cbb20d88 flags:# user_id:long id:int story:flags.0?StoryItem = MessageMedia;
|
||||
|
||||
messageActionEmpty#b6aef7b0 = MessageAction;
|
||||
messageActionChatCreate#bd47cbad title:string users:Vector<long> = MessageAction;
|
||||
|
@ -201,9 +201,9 @@ inputNotifyChats#4a95e84e = InputNotifyPeer;
|
|||
inputNotifyBroadcasts#b1db7c7e = InputNotifyPeer;
|
||||
inputNotifyForumTopic#5c467992 peer:InputPeer top_msg_id:int = InputNotifyPeer;
|
||||
|
||||
inputPeerNotifySettings#df1f002b flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?NotificationSound = InputPeerNotifySettings;
|
||||
inputPeerNotifySettings#e1e51e85 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?NotificationSound stories_muted:flags.6?Bool = InputPeerNotifySettings;
|
||||
|
||||
peerNotifySettings#a83b0426 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int ios_sound:flags.3?NotificationSound android_sound:flags.4?NotificationSound other_sound:flags.5?NotificationSound = PeerNotifySettings;
|
||||
peerNotifySettings#6cdc6e52 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int ios_sound:flags.3?NotificationSound android_sound:flags.4?NotificationSound other_sound:flags.5?NotificationSound stories_muted:flags.6?Bool = PeerNotifySettings;
|
||||
|
||||
peerSettings#a518110d flags:# report_spam:flags.0?true add_contact:flags.1?true block_contact:flags.2?true share_contact:flags.3?true need_contacts_exception:flags.4?true report_geo:flags.5?true autoarchived:flags.7?true invite_members:flags.8?true request_chat_broadcast:flags.10?true geo_distance:flags.6?int request_chat_title:flags.9?string request_chat_date:flags.9?int = PeerSettings;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue