fix: view.vue-config|view.main (do not show notification if already on the target page)

This commit is contained in:
xdrm-brackets 2017-12-05 18:55:07 +01:00
parent 3fd5fdfa97
commit fe1ab69cf0
2 changed files with 21 additions and 3 deletions

View File

@ -42,6 +42,8 @@ new Vue({
render: h => h(wrapper_vue)
});
gstore.data.func.nav(router, null);
/* (3) Set WebSocket channels
---------------------------------------------------------*/
@ -63,6 +65,9 @@ window.wsc_connect = wsc.channel('connect').listen(function(msg, err){
gstore.data.notif[0].count += msg.connected.length;
}
// {4} Reset notification count if already on page //
gstore.data.func.nav(router, null);
}).send({name: _SERVER.session.name});
@ -84,6 +89,10 @@ window.wsc_chat = wsc.channel('chat').listen(function(msg, err){
gstore.data.notif[1].count += msg.msg.length
}
// {4} Reset notification count if already on page //
gstore.data.func.nav(router, null);
}).send({name: _SERVER.session.name});

View File

@ -52,12 +52,21 @@ gstore.add('func', {
nav: function(router, uri){
// {1} Update view (vue-router) //
router.push('/'+uri);
if( typeof uri == 'string' )
router.push('/'+uri);
// {2} Activate current menu_item //
// {2} if no @uri -> Extract route from @router //
else if( /^\/([^\/]+).*$/.test( router.app.$route.path ) )
uri = RegExp.$1;
// {3} If no @uri -> exit //
else
return;
// {4} Activate current menu_item //
gstore.data.menu_item_active = uri;
// {3} Manage notifications //
// {5} Manage notifications //
for( var notif of gstore.data.notif )
if( notif.link == uri ) // if notif links to current page
notif.count = 0;