From 788316726553c4b1d6b2236c21896e5a2a2e2e43 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 5 Mar 2018 18:48:37 -0500 Subject: [PATCH] Fix "None" audio for fallback notifications. // FREEBIE --- SignalMessaging/environment/OWSSounds.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/SignalMessaging/environment/OWSSounds.m b/SignalMessaging/environment/OWSSounds.m index 6d9d89f1d..0634304cd 100644 --- a/SignalMessaging/environment/OWSSounds.m +++ b/SignalMessaging/environment/OWSSounds.m @@ -259,11 +259,18 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob DDLogDebug(@"%@ writing new default sound to %@", self.logTag, defaultSoundPath); NSURL *_Nullable soundURL = [OWSSounds soundURLForSound:sound quiet:NO]; - OWSAssert(soundURL); + + NSData *soundData = ^{ + if (soundURL) { + return [NSData dataWithContentsOfURL:soundURL]; + } else { + OWSAssert(sound == OWSSound_None); + return [NSData new]; + } + }(); // Quick way to achieve an atomic "copy" operation that allows overwriting if the user has previously specified // a default notification sound. - NSData *soundData = [NSData dataWithContentsOfURL:soundURL]; BOOL success = [soundData writeToFile:defaultSoundPath atomically:YES]; // The globally configured sound the user has configured is unprotected, so that we can still play the sound if the