From 8dd886979ec61e5adb73d8c662de07070be75d41 Mon Sep 17 00:00:00 2001 From: Jeff Halter <868228+jhalter@users.noreply.github.com> Date: Sat, 11 May 2024 19:55:17 -0700 Subject: Add "Show Join/Leave in Chat" option --- Hotline/Models/Hotline.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Hotline/Models/Hotline.swift') diff --git a/Hotline/Models/Hotline.swift b/Hotline/Models/Hotline.swift index 5dc61ab..308a764 100644 --- a/Hotline/Models/Hotline.swift +++ b/Hotline/Models/Hotline.swift @@ -810,7 +810,10 @@ class Hotline: Equatable, HotlineClientDelegate, HotlineFileClientDelegate { func hotlineUserDisconnected(userID: UInt16) { if let existingUserIndex = self.users.firstIndex(where: { $0.id == UInt(userID) }) { let user = self.users.remove(at: existingUserIndex) - self.chat.append(ChatMessage(text: "\(user.name) left", type: .status, date: Date())) + + if Prefs.shared.showJoinLeaveMessages { + self.chat.append(ChatMessage(text: "\(user.name) left", type: .status, date: Date())) + } if Prefs.shared.playSounds && Prefs.shared.playLeaveSound { SoundEffectPlayer.shared.playSoundEffect(.userLogout) @@ -928,7 +931,9 @@ class Hotline: Equatable, HotlineClientDelegate, HotlineFileClientDelegate { print("Hotline: added user: \(user.name)") self.users.append(User(hotlineUser: user)) - self.chat.append(ChatMessage(text: "\(user.name) joined", type: .status, date: Date())) + if Prefs.shared.showJoinLeaveMessages { + self.chat.append(ChatMessage(text: "\(user.name) joined", type: .status, date: Date())) + } } } -- cgit