mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-08-29 07:39:23 +00:00
Fix channel chat not showing new messages
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.
This commit is contained in:
+7
-3
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user