From 8cb41e9fce82fc8e209348b51c2b79e6cace8e18 Mon Sep 17 00:00:00 2001 From: Jeff Halter <868228+jhalter@users.noreply.github.com> Date: Wed, 1 May 2024 14:55:19 -0700 Subject: Add sound settings --- Hotline/Models/Hotline.swift | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'Hotline/Models/Hotline.swift') diff --git a/Hotline/Models/Hotline.swift b/Hotline/Models/Hotline.swift index 6b5e3a7..1439755 100644 --- a/Hotline/Models/Hotline.swift +++ b/Hotline/Models/Hotline.swift @@ -636,7 +636,9 @@ final class Hotline: HotlineClientDelegate, HotlineFileClientDelegate { self.deleteAllTransfers() } else if status == .loggedIn { - soundEffects.playSoundEffect(.loggedIn) + if Prefs().playSounds && Prefs().playLoggedInSound { + soundEffects.playSoundEffect(.loggedIn) + } } self.status = status @@ -656,7 +658,9 @@ final class Hotline: HotlineClientDelegate, HotlineFileClientDelegate { } func hotlineReceivedChatMessage(message: String) { - soundEffects.playSoundEffect(.chatMessage) + if Prefs().playSounds && Prefs().playChatSound { + soundEffects.playSoundEffect(.chatMessage) + } self.chat.append(ChatMessage(text: message, type: .message, date: Date())) } @@ -693,7 +697,9 @@ final class Hotline: HotlineClientDelegate, HotlineFileClientDelegate { let user = self.users.remove(at: existingUserIndex) self.chat.append(ChatMessage(text: "\(user.name) left", type: .status, date: Date())) - soundEffects.playSoundEffect(.userLogout) + if Prefs().playSounds && Prefs().playLeaveSound { + soundEffects.playSoundEffect(.userLogout) + } } } @@ -776,8 +782,9 @@ final class Hotline: HotlineClientDelegate, HotlineFileClientDelegate { let transfer = self.transfers[i] transfer.fileURL = at transfer.downloadCallback?(transfer, at) - - soundEffects.playSoundEffect(.transferComplete) + if Prefs().playSounds && Prefs().playFileTransferCompleteSound { + soundEffects.playSoundEffect(.transferComplete) + } } if let i = self.downloads.firstIndex(where: { $0.referenceNumber == reference }) { @@ -798,7 +805,9 @@ final class Hotline: HotlineClientDelegate, HotlineFileClientDelegate { } else { if !self.users.isEmpty { - soundEffects.playSoundEffect(.userLogin) + if Prefs().playSounds && Prefs().playJoinSound { + soundEffects.playSoundEffect(.userLogin) + } } print("Hotline: added user: \(user.name)") -- cgit