diff --git a/server/public/home.html b/server/public/home.html index 89fcf71..f53bf29 100644 --- a/server/public/home.html +++ b/server/public/home.html @@ -589,7 +589,7 @@ - +
Loading…
@@ -1433,7 +1433,10 @@ async function sendMessage(){ try{ const m=await postJSON('/api/messages', payload); composeMentions=new Map(); - THREAD.push(m); appendBubble(m); clearReply(); pendingAttach=null; hideAttach(); + // Dedup by id: the server echoes our message over WS (to sync other tabs) and that echo + // can arrive BEFORE this POST resolves, so onChatMessage may have already appended it. + if(!THREAD.some(x=>x.id===m.id)){ THREAD.push(m); appendBubble(m); } + clearReply(); pendingAttach=null; hideAttach(); { const ck=selected.kind+':'+selected.id; if(THREAD_CACHE.has(ck)){ const a=THREAD_CACHE.get(ck); if(!a.some(x=>x.id===m.id)) a.push(m); } } const it=rowFor(selected.kind,selected.id); if(it){ it.last_body=m.body||(m.attachment?'📎 '+(m.attachment.name||'Attachment'):''); it.last_at=m.created_at; it.last_from_me=true; it.unread=0; }