From 74d1a7f54b9c1eb72ea1fb1791abb87c8e0cb09f Mon Sep 17 00:00:00 2001 From: James Magahern Date: Tue, 9 Sep 2025 18:54:14 -0700 Subject: [PATCH] osx: try badging icon for unread --- osx/kordophone2/ConversationListView.swift | 5 +++++ osx/kordophone2/Models.swift | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/osx/kordophone2/ConversationListView.swift b/osx/kordophone2/ConversationListView.swift index 656de92..444ed50 100644 --- a/osx/kordophone2/ConversationListView.swift +++ b/osx/kordophone2/ConversationListView.swift @@ -101,6 +101,11 @@ struct ConversationListView: View .map { Display.Conversation(from: $0) } self.conversations = clientConversations + + let unreadConversations = clientConversations.filter(\.isUnread) + await MainActor.run { + NSApplication.shared.dockTile.badgeLabel = unreadConversations.isEmpty ? nil : "\(unreadConversations.count)" + } } catch { print("Error reloading conversations: \(error)") } diff --git a/osx/kordophone2/Models.swift b/osx/kordophone2/Models.swift index a53ce69..2acf22a 100644 --- a/osx/kordophone2/Models.swift +++ b/osx/kordophone2/Models.swift @@ -26,7 +26,11 @@ enum Display var isGroupChat: Bool { participants.count > 1 } - + + var isUnread: Bool { + unreadCount > 0 + } + init(from c: Serialized.Conversation) { self.id = c.guid self.name = c.displayName