From 0a046815acd323ed60c832ca81bcd3a1d8b3fd9b Mon Sep 17 00:00:00 2001 From: you Date: Thu, 19 Mar 2026 04:04:50 +0000 Subject: [PATCH] Fix channel chat not showing new messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two bugs: 1. refreshMessages() compared array length to detect changes — at the 200 message limit, new messages don't change the count. Now compares last message timestamp instead. 2. WS handler only triggered on type 'message' — observer-decoded GRP_TXT packets broadcast as type 'packet' were missed. Now also triggers refresh on packet events with GRP_TXT payload type. --- public/channels.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/public/channels.js b/public/channels.js index 0027a5ed..dbe2dc51 100644 --- a/public/channels.js +++ b/public/channels.js @@ -251,9 +251,10 @@ }); wsHandler = (msg) => { - if (msg.type === 'message') { + const isMessage = msg.type === 'message'; + const isChannelPacket = msg.type === 'packet' && msg.data?.decoded?.header?.payloadTypeName === 'GRP_TXT'; + if (isMessage || isChannelPacket) { loadChannels(true); - // Refresh active channel messages if (selectedHash) { refreshMessages(); } @@ -355,7 +356,10 @@ try { const data = await api(`/channels/${selectedHash}/messages?limit=200`); const newMsgs = data.messages || []; - if (newMsgs.length === messages.length) return; // no change + // Compare last message timestamp instead of count — count stays same at limit + const lastOld = messages.length ? messages[messages.length - 1]?.timestamp : null; + const lastNew = newMsgs.length ? newMsgs[newMsgs.length - 1]?.timestamp : null; + if (newMsgs.length === messages.length && lastOld === lastNew) return; messages = newMsgs; renderMessages(); if (wasAtBottom) scrollToBottom();