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 committed by SeekDaSky
parent e8d385f1f6
commit f3e3f1496b
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 //
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;
}