From 1ac649c4d5c91106799d69e653bf4bf7e4fcf376 Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Tue, 26 Apr 2016 05:41:20 -0700 Subject: PLT-2675 fixing blue bar on logout and re-login (#2798) --- webapp/action_creators/websocket_actions.jsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'webapp') diff --git a/webapp/action_creators/websocket_actions.jsx b/webapp/action_creators/websocket_actions.jsx index c4e9c63c2..a1368ac99 100644 --- a/webapp/action_creators/websocket_actions.jsx +++ b/webapp/action_creators/websocket_actions.jsx @@ -66,6 +66,10 @@ export function initialize() { console.log('websocket closed'); //eslint-disable-line no-console } + if (manuallyClosed) { + return; + } + connectFailCount = connectFailCount + 1; if (connectFailCount > MAX_WEBSOCKET_FAILS) { @@ -75,14 +79,12 @@ export function initialize() { ErrorStore.setConnectionErrorCount(connectFailCount); ErrorStore.emitChange(); - if (!manuallyClosed) { - setTimeout( - () => { - initialize(); - }, - WEBSOCKET_RETRY_TIME - ); - } + setTimeout( + () => { + initialize(); + }, + WEBSOCKET_RETRY_TIME + ); }; conn.onerror = (evt) => { @@ -161,6 +163,7 @@ export function sendMessage(msg) { export function close() { manuallyClosed = true; + connectFailCount = 0; if (conn && conn.readyState === WebSocket.OPEN) { conn.close(); } -- cgit v1.2.3-1-g7c22