feat: send without sound

This commit is contained in:
AlexeyZavar 2024-09-11 22:41:03 +03:00
parent 5bd66f9a76
commit 66b7a48352
4 changed files with 35 additions and 0 deletions

View file

@ -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;
}

View file

@ -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,

View file

@ -559,6 +559,28 @@ void SetupGhostEssentials(not_null<Ui::VerticalLayout*> 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<Ui::VerticalLayout*> container) {

View file

@ -220,6 +220,11 @@ QString NewMessagePostAuthor(const Api::SendAction &action) {
bool ShouldSendSilent(
not_null<PeerData*> 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))