diff --git a/Telegram/SourceFiles/ayu/ayu_settings.cpp b/Telegram/SourceFiles/ayu/ayu_settings.cpp index a40a2de83..d5168cf3e 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.cpp +++ b/Telegram/SourceFiles/ayu/ayu_settings.cpp @@ -203,6 +203,7 @@ AyuGramSettings::AyuGramSettings() { markReadAfterAction = true; useScheduledMessages = false; + sendWithoutSound = false; // ~ Message edits & deletion history saveDeletedMessages = true; @@ -331,6 +332,10 @@ void AyuGramSettings::set_useScheduledMessages(bool val) { useScheduledMessages = val; } +void AyuGramSettings::set_sendWithoutSound(bool val) { + sendWithoutSound = val; +} + void AyuGramSettings::set_saveDeletedMessages(bool val) { saveDeletedMessages = val; } diff --git a/Telegram/SourceFiles/ayu/ayu_settings.h b/Telegram/SourceFiles/ayu/ayu_settings.h index a6a3c27b8..a68106ae0 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.h +++ b/Telegram/SourceFiles/ayu/ayu_settings.h @@ -25,6 +25,7 @@ public: bool markReadAfterAction; bool useScheduledMessages; + bool sendWithoutSound; bool saveDeletedMessages; bool saveMessagesHistory; @@ -90,6 +91,7 @@ public: void set_markReadAfterAction(bool val); void set_useScheduledMessages(bool val); + void set_sendWithoutSound(bool val); void set_saveDeletedMessages(bool val); void set_saveMessagesHistory(bool val); @@ -155,6 +157,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( sendOfflinePacketAfterOnline, markReadAfterAction, useScheduledMessages, + sendWithoutSound, saveDeletedMessages, saveMessagesHistory, hideFromBlocked, diff --git a/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.cpp b/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.cpp index 8835ca8a5..c3860948e 100644 --- a/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.cpp +++ b/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.cpp @@ -559,6 +559,28 @@ void SetupGhostEssentials(not_null container) { container->lifetime()); AddSkip(container); AddDividerText(container, tr::ayu_UseScheduledMessagesDescription()); + + AddSkip(container); + AddButtonWithIcon( + container, + tr::ayu_SendWithoutSoundByDefault(), + st::settingsButtonNoIcon + )->toggleOn( + rpl::single(settings->sendWithoutSound) + )->toggledValue( + ) | rpl::filter( + [=](bool enabled) + { + return (enabled != settings->sendWithoutSound); + }) | start_with_next( + [=](bool enabled) + { + settings->set_sendWithoutSound(enabled); + AyuSettings::save(); + }, + container->lifetime()); + AddSkip(container); + AddDividerText(container, tr::ayu_SendWithoutSoundByDefaultDescription()); } void SetupSpyEssentials(not_null container) { diff --git a/Telegram/SourceFiles/history/history_item_helpers.cpp b/Telegram/SourceFiles/history/history_item_helpers.cpp index cc1a8c15f..fa79b218b 100644 --- a/Telegram/SourceFiles/history/history_item_helpers.cpp +++ b/Telegram/SourceFiles/history/history_item_helpers.cpp @@ -220,6 +220,11 @@ QString NewMessagePostAuthor(const Api::SendAction &action) { bool ShouldSendSilent( not_null peer, const Api::SendOptions &options) { + const auto settings = &AyuSettings::getInstance(); + if (settings->sendWithoutSound) { + return true; + } + return options.silent || (peer->isBroadcast() && peer->owner().notifySettings().silentPosts(peer))