From 5fa3fcf60f55ad279c2d351cec55a71e9fb86633 Mon Sep 17 00:00:00 2001 From: padreug Date: Fri, 8 Aug 2025 21:52:16 +0200 Subject: [PATCH] feat: Add unread message notifications and tracking in Nostr chat - Implement unread message indicators in the ChatComponent for both total unread messages and per-peer unread counts. - Enhance the useNostrChat composable to manage unread message data, including saving and loading unread counts from localStorage. - Introduce methods to mark messages as read and update unread counts dynamically as new messages are received. - Refactor the message handling logic to ensure accurate tracking of unread messages based on the last read timestamp. --- src/components/nostr/ChatComponent.vue | 92 +++++++++---- src/composables/useNostrChat.ts | 175 ++++++++++++++++++++++--- 2 files changed, 219 insertions(+), 48 deletions(-) diff --git a/src/components/nostr/ChatComponent.vue b/src/components/nostr/ChatComponent.vue index 8d95a01..b27ede6 100644 --- a/src/components/nostr/ChatComponent.vue +++ b/src/components/nostr/ChatComponent.vue @@ -12,6 +12,10 @@ Disconnected + + + {{ getTotalUnreadCount() }} unread + - - - {{ selectedPeer ? getPeerInitials(selectedPeer) : 'U' }} - -
-

{{ selectedPeer?.username || 'Unknown User' }}

-

- {{ selectedPeer ? formatPubkey(selectedPeer.pubkey) : '' }} -

-
+
+ + + + {{ selectedPeer ? getPeerInitials(selectedPeer) : 'U' }} + +
+

{{ selectedPeer?.username || 'Unknown User' }}

+

+ {{ selectedPeer ? formatPubkey(selectedPeer.pubkey) : '' }} +

- - Connected - - - Disconnected - +
+
+ + Connected + + + Disconnected + + + + {{ getUnreadCount(selectedPeer.pubkey) }} unread + +
@@ -181,6 +197,10 @@ Disconnected + + + {{ getTotalUnreadCount() }} unread +