diff --git a/view/main.js b/view/main.js index c80abed..ebb360e 100755 --- a/view/main.js +++ b/view/main.js @@ -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}); diff --git a/view/vue-config.js b/view/vue-config.js index 8984fca..b1277c1 100644 --- a/view/vue-config.js +++ b/view/vue-config.js @@ -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;