From 0471c4c4594f0406e85687ef84a29d99616c16cf Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Fri, 3 May 2024 14:05:56 -0700 Subject: Add unread badge to public chat in sidebar. Display server messages. --- Hotline/Models/Hotline.swift | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Hotline/Models') diff --git a/Hotline/Models/Hotline.swift b/Hotline/Models/Hotline.swift index 564845a..ccc23c1 100644 --- a/Hotline/Models/Hotline.swift +++ b/Hotline/Models/Hotline.swift @@ -136,6 +136,7 @@ class Hotline: Equatable, HotlineClientDelegate, HotlineFileClientDelegate { var transfers: [TransferInfo] = [] var downloads: [HotlineFileClient] = [] var unreadInstantMessages: [UInt16:UInt16] = [:] + var unreadPublicChat: Bool = false @ObservationIgnored var bannerClient: HotlineFileClient? #if os(macOS) @@ -226,6 +227,10 @@ class Hotline: Equatable, HotlineClientDelegate, HotlineFileClientDelegate { } } + func markPublicChatAsRead() { + self.unreadPublicChat = false + } + func hasUnreadInstantMessages(userID: UInt16) -> Bool { return self.unreadInstantMessages[userID] != nil } @@ -737,6 +742,7 @@ class Hotline: Equatable, HotlineClientDelegate, HotlineFileClientDelegate { SoundEffectPlayer.shared.playSoundEffect(.chatMessage) } self.chat.append(ChatMessage(text: message, type: .message, date: Date())) + self.unreadPublicChat = true } func hotlineReceivedUserList(users: [HotlineUser]) { -- cgit