From c107e6c38b2e37104eb1fde7392b695e9b264c54 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 6 Dec 2017 19:10:16 +0100 Subject: [PATCH] fix: view.main (fixed no notification if on current page, added '/' before router path check) --- view/main.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/view/main.js b/view/main.js index 5969353..4094463 100755 --- a/view/main.js +++ b/view/main.js @@ -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}); \ No newline at end of file