diff --git a/webpack/lib/content-controller.js b/webpack/lib/content-controller.js index 8895313..b8e0933 100644 --- a/webpack/lib/content-controller.js +++ b/webpack/lib/content-controller.js @@ -17,6 +17,11 @@ export default class ContentController{ } }; + /* (2) Manage updates in connection status (ONLINE - OFFLINE) */ + window.addEventListener('online', this.ws_connect.bind(this)); + window.addEventListener('offline', function(){ gs.get.connection = 0; }); // connection status bar + + } @@ -210,13 +215,17 @@ export default class ContentController{ // 1. update connection status bar gs.get.connection = 0; - // 2. Check connection offline - let online = navigator.onLine; - - // 3. do not reconnect if max attempt exceeded (and if not offline of course) - if( online && gs.get.content.attempt.count >= gs.get.content.attempt.max-1 ) + // 2. Do nothing if offline (online trigger will do the job when online again) + if( !navigator.onLine ) return; + // 3. if max attempt exceeded -> logout user + if( gs.get.content.attempt.count >= gs.get.content.attempt.max-1 ){ + auth.token = null; + gs.get.refresh(); + return; + } + // 4. Try to reconnect return setTimeout(gs.get.content.ws_connect.bind(gs.get.content), gs.get.content.attempt.timeout); } diff --git a/webpack/scss/layout.scss b/webpack/scss/layout.scss index 1da72a7..43b2e64 100644 --- a/webpack/scss/layout.scss +++ b/webpack/scss/layout.scss @@ -50,7 +50,7 @@ body > #WRAPPER > #CONNECTION_STATUS{ padding: .3em 0; - // background-color: #d83636; + background-color: #32ce80; font-size: 1em; text-align: center;