diff options
author | JoramWilander <jwawilander@gmail.com> | 2016-03-24 20:12:36 -0400 |
---|---|---|
committer | JoramWilander <jwawilander@gmail.com> | 2016-03-24 20:12:36 -0400 |
commit | 6516e9bf6801f7c9ec247b2397503a834c93d790 (patch) | |
tree | e008feb1f2441ab720c7ba64ebabdcbf61b89eba | |
parent | 8f5b90fe7858de03ac055b38ab7aaec5f54fa107 (diff) | |
download | chat-6516e9bf6801f7c9ec247b2397503a834c93d790.tar.gz chat-6516e9bf6801f7c9ec247b2397503a834c93d790.tar.bz2 chat-6516e9bf6801f7c9ec247b2397503a834c93d790.zip |
Fix websocket trying to reconnect after a logout
-rw-r--r-- | webapp/action_creators/websocket_actions.jsx | 18 | ||||
-rw-r--r-- | webapp/components/signup_team_complete/components/signup_team_complete.jsx | 2 |
2 files changed, 13 insertions, 7 deletions
diff --git a/webapp/action_creators/websocket_actions.jsx b/webapp/action_creators/websocket_actions.jsx index 611d53bf7..009bb9e96 100644 --- a/webapp/action_creators/websocket_actions.jsx +++ b/webapp/action_creators/websocket_actions.jsx @@ -21,6 +21,7 @@ const WEBSOCKET_RETRY_TIME = 3000; var conn = null; var connectFailCount = 0; var pastFirstInit = false; +var manuallyClosed = false; export function initialize() { if (window.WebSocket && !conn) { @@ -35,6 +36,8 @@ export function initialize() { console.log('websocket connecting to ' + connUrl); //eslint-disable-line no-console } + manuallyClosed = false; + conn = new WebSocket(connUrl); conn.onopen = () => { @@ -69,12 +72,14 @@ export function initialize() { ErrorStore.setConnectionErrorCount(connectFailCount); ErrorStore.emitChange(); - setTimeout( - () => { - initialize(); - }, - WEBSOCKET_RETRY_TIME - ); + if (!manuallyClosed) { + setTimeout( + () => { + initialize(); + }, + WEBSOCKET_RETRY_TIME + ); + } }; conn.onerror = (evt) => { @@ -147,6 +152,7 @@ export function sendMessage(msg) { } export function close() { + manuallyClosed = true; if (conn && conn.readyState === WebSocket.OPEN) { conn.close(); } diff --git a/webapp/components/signup_team_complete/components/signup_team_complete.jsx b/webapp/components/signup_team_complete/components/signup_team_complete.jsx index 8b2096499..d21f4d7a9 100644 --- a/webapp/components/signup_team_complete/components/signup_team_complete.jsx +++ b/webapp/components/signup_team_complete/components/signup_team_complete.jsx @@ -55,7 +55,7 @@ export default class SignupTeamComplete extends React.Component { <div> <div className='signup-header'> <Link to='/'> - <span classNameName='fa fa-chevron-left'/> + <span className='fa fa-chevron-left'/> <FormattedMessage id='web.header.back'/> </Link> </div> |