diff --git a/view/websocket.js b/view/websocket.js index d51af78..f79e96b 100644 --- a/view/websocket.js +++ b/view/websocket.js @@ -33,9 +33,6 @@ window.wsc_emergency = wsc.channel('emergency/31').listen(function(msg, err){ } - // if( gstore.data.notif.emergency.data[id] == null ) - // gstore.data.notif.emergency.data[id] = msg.add[id]; - // {3} Add notification count if not already on page // if( router.app.$route.path != '/emergency' ) gstore.data.notif.emergency.count += msg.add.length; @@ -90,9 +87,14 @@ window.wsc_event = wsc.channel('event/31').listen(function(msg, err){ ( new Audio('https://notificationsounds.com/message-tones/communication-channel-519/download/mp3') ).play(); // {2} Add messages to stack // - for( var id in msg.add ) - if( gstore.data.notif.event.data[id] == null ) - gstore.data.notif.event.data[id] = msg.add[id]; + for( var id in msg.add ){ + + var tmp = msg.add[id]; // add id to data + tmp.id = id; + + gstore.data.notif.event.data.push(tmp); + + } // {3} Add notification count if not already on page // if( router.app.$route.path != '/event' ) @@ -104,9 +106,9 @@ window.wsc_event = wsc.channel('event/31').listen(function(msg, err){ if( msg.del != null ){ // {1} Rem messages from stack // - for( var id of msg.del ) - if( gstore.data.notif.event.data[id] != null ) - delete gstore.data.notif.event.data[id]; + for( var id in gstore.data.notif.event.data ) + if( msg.del[ gstore.data.notif.event.data[id].id ] != null ) + gstore.data.notif.event.data[id].message = 'L\'auteur n\'a pas assumé ce message.. Honte à lui !'; } @@ -114,9 +116,9 @@ window.wsc_event = wsc.channel('event/31').listen(function(msg, err){ if( msg.upd != null ){ // {1} Update messages in stack // - for( var id of msg.upd ) - if( gstore.data.notif.event.data[id] != null ) - gstore.data.notif.event.data[id] = msg.upd[id]; + for( var id in gstore.data.notif.event.data ) + if( msg.upd[ gstore.data.notif.event.data[id].id ] != null ) + gstore.data.notif.event.data[id] = msg.upd; }