diff --git a/app.js b/app.js index e85c1bb..c18a07b 100644 --- a/app.js +++ b/app.js @@ -115,6 +115,8 @@ function handleIncomingMessage(msg) { if (!msg) return; // console.log('[WS] handleIncomingMessage payload:', msg); + + ui.updateChatInChatList(msg); const rawChatId = msg.chatId || msg.from || (msg.chat && msg.chat.id); const msgChatId = normalizeChatId(rawChatId); @@ -124,7 +126,9 @@ function handleIncomingMessage(msg) { } // console.log('[WS] Resolved msgChatId:', msgChatId, '| activeChatState:', activeChatState?.id); - messageTone.play(); + if (msg.fromMe) { + messageTone.play(); + } if (activeChatState && activeChatState.id === msgChatId) { const msgId = normalizeChatId(msg.id) || msg.id; diff --git a/ui.js b/ui.js index f852054..abfa8be 100644 --- a/ui.js +++ b/ui.js @@ -92,6 +92,7 @@ export const ui = { } for (const chat of chats) { + console.log(chat); const li = document.createElement('li'); li.className = `chat-item ${activeChat && activeChat.id === chat.id ? 'active' : ''}`; li.dataset.id = chat.id; @@ -119,6 +120,11 @@ export const ui = { elements.chatList.appendChild(li); } }, + + async updateChatInChatList(msg) { + const li = document.getElementById(msg.from); + li.querySelector(".chat-item-msg").innerText = msg.body; + }, /** * Render chat message log inside chat view container diff --git a/waha.js b/waha.js index 106d5d5..3c3050f 100644 --- a/waha.js +++ b/waha.js @@ -73,7 +73,7 @@ export const waha = { }, async getChats() { - const data = await request(`/api/${config.session}/chats?sortBy=conversationTimestamp`); + const data = await request(`/api/${config.session}/chats`); return data.map(chat => { let chatId = chat.id; if (chatId && typeof chatId === "object") {