create setting to disable message sent sounds

This commit is contained in:
Ehren Kret 2026-04-17 11:00:15 -05:00 committed by GitHub
parent 472dc49f31
commit d4fa2a3ec6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 27 additions and 0 deletions

View File

@ -56,6 +56,7 @@ extension ConversationViewController: ConversationInputToolbarDelegate {
if
SSKEnvironment.shared.preferencesRef.soundInForeground,
SSKEnvironment.shared.preferencesRef.isMessageSentSoundEnabled,
let soundId = Sounds.systemSoundIDForSound(.standard(.messageSent), quiet: true)
{
AudioServicesPlaySystemSound(soundId)

View File

@ -49,6 +49,15 @@ class NotificationSettingsViewController: OWSTableViewController2 {
target: self,
selector: #selector(didToggleSoundNotificationsSwitch),
))
soundsSection.add(.switch(
withText: OWSLocalizedString(
"SETTINGS_MESSAGE_SENT_SOUND",
comment: "Setting for enabling & disabling the sound effect played when a message is sent.",
),
isOn: { SSKEnvironment.shared.preferencesRef.isMessageSentSoundEnabled },
target: self,
selector: #selector(didToggleMessageSentSoundSwitch),
))
contents.add(soundsSection)
let notificationContentSection = OWSTableSection()
@ -125,6 +134,11 @@ class NotificationSettingsViewController: OWSTableViewController2 {
SSKEnvironment.shared.preferencesRef.setSoundInForeground(sender.isOn)
}
@objc
private func didToggleMessageSentSoundSwitch(_ sender: UISwitch) {
SSKEnvironment.shared.preferencesRef.setIsMessageSentSoundEnabled(sender.isOn)
}
@objc
private func didToggleIncludesMutedConversationsInBadgeCountSwitch(_ sender: UISwitch) {
SSKEnvironment.shared.databaseStorageRef.write { tx in SSKPreferences.setIncludeMutedThreadsInBadgeCount(sender.isOn, transaction: tx) }

View File

@ -8473,6 +8473,9 @@
/* Label for the 'video' attachment type in the media download settings. */
"SETTINGS_MEDIA_DOWNLOAD_TYPE_VIDEO" = "Videos";
/* Setting for enabling & disabling the sound effect played when a message is sent. */
"SETTINGS_MESSAGE_SENT_SOUND" = "Message Sent Sound";
/* Explanation for the 'messaging' privacy settings. */
"SETTINGS_MESSAGING_FOOTER" = "See and share when messages are being read and typed. If disabled, you wont see read receipts or typing indicators from others.";

View File

@ -28,6 +28,7 @@ public class Preferences {
case screenSecurity = "Screen Security Key"
case notificationPreviewType = "Notification Preview Type Key"
case playSoundInForeground = "NotificationSoundInForeground"
case messageSentSound = "MessageSentSound"
case lastRecordedPushToken = "LastRecordedPushToken"
case callsHideIPAddress = "CallsHideIPAddress"
case hasDeclinedNoContactsView = "hasDeclinedNoContactsView"
@ -282,6 +283,14 @@ public class Preferences {
setBool(value, forKey: .playSoundInForeground)
}
public var isMessageSentSoundEnabled: Bool {
bool(forKey: .messageSentSound, defaultValue: true)
}
public func setIsMessageSentSoundEnabled(_ value: Bool) {
setBool(value, forKey: .messageSentSound)
}
public func notificationPreviewType(tx: DBReadTransaction) -> NotificationType {
let rawValue = keyValueStore.getUInt(
Key.notificationPreviewType.rawValue,