fix: view.main (fixed no notification if on current page, added '/' before router path check)

This commit is contained in:
xdrm-brackets 2017-12-06 19:10:16 +01:00
parent 926f5d1224
commit c107e6c38b
1 changed files with 6 additions and 5 deletions

View File

@ -74,7 +74,7 @@ window.wsc_connect = wsc.channel('connect').listen(function(msg, err){
gstore.data.notif[0].data = gstore.data.notif[0].data.filter(function(item, i, arr){ return arr.indexOf(item) === i; });
// -3- Update count if not already on page
if( router.app.$route.path != 'notifications' )
if( router.app.$route.path != '/notifications' )
gstore.data.notif[0].count += gstore.data.notif[0].data.length - lastLen;
}
@ -88,7 +88,7 @@ window.wsc_connect = wsc.channel('connect').listen(function(msg, err){
gstore.data.notif[0].data = gstore.data.notif[0].data.filter(function(item){ return msg.disconnected.indexOf(item) === -1; });
// -2- Update count if not already on page
if( router.app.$route.path != 'notifications' )
if( router.app.$route.path != '/notifications' )
gstore.data.notif[0].count += lastLen - gstore.data.notif[0].data.length;
}
@ -112,14 +112,15 @@ window.wsc_chat = wsc.channel('chat').listen(function(msg, err){
return;
// {4} Play sound if 1msg received + not already on page //
if( msg.msg.length == 1 && router.app.$route.path != 'inbox' )
// note: 1msg means a new message but not the page load past buffer
if( msg.msg.length == 1 && router.app.$route.path != '/inbox' )
( new Audio('/sound/notification.mp3') ).play();
// {5} Add messages to stack //
gstore.data.notif[1].data = gstore.data.notif[1].data.concat( msg.msg );
// {6} Add notification count if not already on page //
if( router.app.$route.path != 'inbox' )
gstore.data.notif[1].count += msg.msg.length
if( router.app.$route.path != '/inbox' )
gstore.data.notif[1].count += msg.msg.length;
}).send({name: _SERVER.session.name});