Disconnect the websocket on logout and connect appropiately (#2375)

This commit is contained in:
Elias Nahum 2018-11-23 14:54:43 -03:00 committed by GitHub
parent 7c711caf2d
commit a03016a9e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -81,6 +81,10 @@ export default class NetworkIndicator extends PureComponent {
this.mounted = true;
AppState.addEventListener('change', this.handleAppStateChange);
// Attempt to connect when this component mounts
// if the websocket is already connected it does not try and connect again
this.connect();
}
componentDidUpdate(prevProps) {

View file

@ -20,9 +20,11 @@ import {Provider} from 'react-redux';
import semver from 'semver';
import {Client4} from 'mattermost-redux/client';
import {General} from 'mattermost-redux/constants';
import {setAppState, setServerVersion} from 'mattermost-redux/actions/general';
import {loadMe, logout} from 'mattermost-redux/actions/users';
import {close as closeWebSocket} from 'mattermost-redux/actions/websocket';
import {General} from 'mattermost-redux/constants';
import {handleLoginIdChanged} from 'app/actions/views/login';
import {handleServerUrlChanged} from 'app/actions/views/select_server';
import EventEmitter from 'mattermost-redux/utils/event_emitter';
@ -141,6 +143,7 @@ const handleLogout = () => {
// the Client online flag to true cause the network handler
// is not available at this point
Client4.setOnline(true);
store.dispatch(closeWebSocket(false));
app.setAppStarted(true);
app.clearNativeCache();