IMPORTANT fix: websocket (now will work also for '/event' channel

This commit is contained in:
xdrm-brackets 2017-12-08 00:01:25 +01:00
parent b12eb46939
commit 56b4327184
1 changed files with 14 additions and 12 deletions

View File

@ -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 // // {3} Add notification count if not already on page //
if( router.app.$route.path != '/emergency' ) if( router.app.$route.path != '/emergency' )
gstore.data.notif.emergency.count += msg.add.length; 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(); ( new Audio('https://notificationsounds.com/message-tones/communication-channel-519/download/mp3') ).play();
// {2} Add messages to stack // // {2} Add messages to stack //
for( var id in msg.add ) for( var id in msg.add ){
if( gstore.data.notif.event.data[id] == null )
gstore.data.notif.event.data[id] = msg.add[id]; 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 // // {3} Add notification count if not already on page //
if( router.app.$route.path != '/event' ) 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 ){ if( msg.del != null ){
// {1} Rem messages from stack // // {1} Rem messages from stack //
for( var id of msg.del ) for( var id in gstore.data.notif.event.data )
if( gstore.data.notif.event.data[id] != null ) if( msg.del[ gstore.data.notif.event.data[id].id ] != null )
delete gstore.data.notif.event.data[id]; 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 ){ if( msg.upd != null ){
// {1} Update messages in stack // // {1} Update messages in stack //
for( var id of msg.upd ) for( var id in gstore.data.notif.event.data )
if( gstore.data.notif.event.data[id] != null ) if( msg.upd[ gstore.data.notif.event.data[id].id ] != null )
gstore.data.notif.event.data[id] = msg.upd[id]; gstore.data.notif.event.data[id] = msg.upd;
} }