Don't play notification sound when msg.fromMe
This commit is contained in:
parent
3ba0f9792c
commit
9480c600f9
3 changed files with 12 additions and 2 deletions
6
app.js
6
app.js
|
|
@ -116,6 +116,8 @@ function handleIncomingMessage(msg) {
|
||||||
|
|
||||||
// console.log('[WS] handleIncomingMessage payload:', msg);
|
// console.log('[WS] handleIncomingMessage payload:', msg);
|
||||||
|
|
||||||
|
ui.updateChatInChatList(msg);
|
||||||
|
|
||||||
const rawChatId = msg.chatId || msg.from || (msg.chat && msg.chat.id);
|
const rawChatId = msg.chatId || msg.from || (msg.chat && msg.chat.id);
|
||||||
const msgChatId = normalizeChatId(rawChatId);
|
const msgChatId = normalizeChatId(rawChatId);
|
||||||
if (!msgChatId) {
|
if (!msgChatId) {
|
||||||
|
|
@ -124,7 +126,9 @@ function handleIncomingMessage(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log('[WS] Resolved msgChatId:', msgChatId, '| activeChatState:', activeChatState?.id);
|
// console.log('[WS] Resolved msgChatId:', msgChatId, '| activeChatState:', activeChatState?.id);
|
||||||
messageTone.play();
|
if (msg.fromMe) {
|
||||||
|
messageTone.play();
|
||||||
|
}
|
||||||
|
|
||||||
if (activeChatState && activeChatState.id === msgChatId) {
|
if (activeChatState && activeChatState.id === msgChatId) {
|
||||||
const msgId = normalizeChatId(msg.id) || msg.id;
|
const msgId = normalizeChatId(msg.id) || msg.id;
|
||||||
|
|
|
||||||
6
ui.js
6
ui.js
|
|
@ -92,6 +92,7 @@ export const ui = {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const chat of chats) {
|
for (const chat of chats) {
|
||||||
|
console.log(chat);
|
||||||
const li = document.createElement('li');
|
const li = document.createElement('li');
|
||||||
li.className = `chat-item ${activeChat && activeChat.id === chat.id ? 'active' : ''}`;
|
li.className = `chat-item ${activeChat && activeChat.id === chat.id ? 'active' : ''}`;
|
||||||
li.dataset.id = chat.id;
|
li.dataset.id = chat.id;
|
||||||
|
|
@ -120,6 +121,11 @@ export const ui = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
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
|
* Render chat message log inside chat view container
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
2
waha.js
2
waha.js
|
|
@ -73,7 +73,7 @@ export const waha = {
|
||||||
},
|
},
|
||||||
|
|
||||||
async getChats() {
|
async getChats() {
|
||||||
const data = await request(`/api/${config.session}/chats?sortBy=conversationTimestamp`);
|
const data = await request(`/api/${config.session}/chats`);
|
||||||
return data.map(chat => {
|
return data.map(chat => {
|
||||||
let chatId = chat.id;
|
let chatId = chat.id;
|
||||||
if (chatId && typeof chatId === "object") {
|
if (chatId && typeof chatId === "object") {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue