From f5d7903ecbd4d84ba6168c3cfb0c70f0f582bbcb Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Mon, 8 Dec 2014 16:25:38 +0000 Subject: [PATCH] Stop lost connection message bouncing when not authed --- public/red/comms.js | 11 +++++++++-- red/api/auth/strategies.js | 1 - 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/public/red/comms.js b/public/red/comms.js index 4d352a2a7..8f672bb6d 100644 --- a/public/red/comms.js +++ b/public/red/comms.js @@ -17,6 +17,8 @@ RED.comms = (function() { var errornotification = null; + var clearErrorTimer = null; + var subscriptions = {}; var ws; function connectWS() { @@ -26,8 +28,10 @@ RED.comms = (function() { ws = new WebSocket(path); ws.onopen = function() { if (errornotification) { - errornotification.close(); - errornotification = null; + clearErrorTimer = setTimeout(function() { + errornotification.close(); + errornotification = null; + },1000); } var auth_tokens = RED.settings.get("auth-tokens"); if (auth_tokens) { @@ -60,6 +64,9 @@ RED.comms = (function() { ws.onclose = function() { if (errornotification == null) { errornotification = RED.notify("Error: Lost connection to server","error",true); + } else if (clearErrorTimer) { + clearTimeout(clearErrorTimer); + clearErrorTimer = null; } setTimeout(connectWS,1000); } diff --git a/red/api/auth/strategies.js b/red/api/auth/strategies.js index f128e87ed..5831c1731 100644 --- a/red/api/auth/strategies.js +++ b/red/api/auth/strategies.js @@ -28,7 +28,6 @@ var bearerStrategy = function (accessToken, done) { Tokens.get(accessToken).then(function(token) { if (token) { Users.get(token.user).then(function(user) { - console.log(user); if (user) { done(null,{username:user.username},{scope:token.scope}); } else {