Fix "None" audio for fallback notifications.

// FREEBIE
This commit is contained in:
Michael Kirk 2018-03-05 18:48:37 -05:00
parent d3be2b4a3b
commit 7883167265
1 changed files with 9 additions and 2 deletions

View File

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