Returns the message

This commit is contained in:
Pierre HUBERT 2020-04-01 14:19:56 +02:00
parent 11b11ff289
commit 6f4e543876
2 changed files with 14 additions and 1 deletions

View File

@ -191,6 +191,10 @@ class UserWebSocket {
SendEvent("newNumberUnreadConvs", msg.data) SendEvent("newNumberUnreadConvs", msg.data)
break; break;
case "new_conv_message":
SendEvent("newConvMessage", msg.data);
break;
default: default:
console.error("WS Unspported kind of message!", msg); console.error("WS Unspported kind of message!", msg);
break; break;

View File

@ -6,7 +6,7 @@
* @author Pierre HUBERT * @author Pierre HUBERT
*/ */
ComunicWeb.components.conversations.service = { const ConvService = {
/** /**
* @var {Object} __serviceCache The service cache * @var {Object} __serviceCache The service cache
@ -130,6 +130,15 @@ ComunicWeb.components.conversations.service = {
}, },
} }
ComunicWeb.components.conversations.service = ConvService;
//Register service cache //Register service cache
ComunicWeb.common.cacheManager.registerCacheCleaner("ComunicWeb.components.conversations.service.emptyCache"); ComunicWeb.common.cacheManager.registerCacheCleaner("ComunicWeb.components.conversations.service.emptyCache");
// Register to new messages
document.addEventListener("newConvMessage", (e) => {
const msg = e.detail;
if(ConvService.__serviceCache.hasOwnProperty("conversation-" + msg.convID))
ComunicWeb.components.conversations.chatWindows.addMessage(msg.convID, msg);
})