From 24c873edb4461f0dc55f87339372202d75107cb4 Mon Sep 17 00:00:00 2001 From: Miroslav Pejic Date: Sat, 18 Apr 2026 11:25:19 +0200 Subject: [PATCH] [call-me] - feat: add unread message count badge on sidebar button and fix chat notification visibility --- package-lock.json | 4 ++-- package.json | 2 +- public/client.js | 18 ++++++++++++++++-- public/index.html | 1 + public/style.css | 43 ++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 62 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2509f4c..4d58ed9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "call-me", - "version": "1.3.38", + "version": "1.3.39", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "call-me", - "version": "1.3.38", + "version": "1.3.39", "license": "AGPLv3", "dependencies": { "@ngrok/ngrok": "1.7.0", diff --git a/package.json b/package.json index cb132a5..d60c2eb 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "call-me", - "version": "1.3.38", + "version": "1.3.39", "description": "Your Go-To for Instant Video Calls", "author": "Miroslav Pejic - miroslav.pejic.85@gmail.com", "license": "AGPLv3", diff --git a/public/client.js b/public/client.js index ab22b20..f07fd5d 100755 --- a/public/client.js +++ b/public/client.js @@ -35,6 +35,7 @@ const chatContent = document.getElementById('chatContent'); const settingsContent = document.getElementById('settingsContent'); const chatNotification = document.getElementById('chatNotification'); const participantCount = document.getElementById('participantCount'); +const messageCount = document.getElementById('messageCount'); const chatMessages = document.getElementById('chatMessages'); const chatForm = document.getElementById('chatForm'); const chatInput = document.getElementById('chatInput'); @@ -596,6 +597,11 @@ function handleListeners() { sidebarBtn.addEventListener('click', (e) => { e.stopPropagation(); userSidebar.classList.toggle('active'); + // Clear message badge when opening sidebar with chat tab active + if (userSidebar.classList.contains('active') && currentTab === 'chat') { + unreadMessages = 0; + updateChatNotification(); + } }); // Utility to handle click outside for any element @@ -2806,6 +2812,14 @@ function updateChatNotification() { chatNotification.classList.add('hidden'); } } + if (messageCount) { + if (unreadMessages > 0) { + messageCount.textContent = unreadMessages > 99 ? '99+' : unreadMessages.toString(); + messageCount.classList.remove('hidden'); + } else { + messageCount.classList.add('hidden'); + } + } } // Chat form handler @@ -2856,7 +2870,7 @@ function addChatMessage(msg, isSelf = false) { chatMessages.scrollTop = chatMessages.scrollHeight; // Handle unread message counter - if (!isSelf && currentTab !== 'chat') { + if (!isSelf && (currentTab !== 'chat' || !userSidebar.classList.contains('active'))) { unreadMessages++; updateChatNotification(); @@ -2903,7 +2917,7 @@ function addFileMessageToChat({ from, name, size, url, isSelf }) { chatMessages.scrollTop = chatMessages.scrollHeight; // Handle unread message counter for received files - if (!isSelf && currentTab !== 'chat') { + if (!isSelf && (currentTab !== 'chat' || !userSidebar.classList.contains('active'))) { unreadMessages++; updateChatNotification(); diff --git a/public/index.html b/public/index.html index bd114a9..0ae3c81 100755 --- a/public/index.html +++ b/public/index.html @@ -283,6 +283,7 @@ > +