Fix console errors when logging out (#4915)

This commit is contained in:
Joram Wilander
2016-12-29 15:48:46 -05:00
committed by Christopher Speller
parent 5811acca7f
commit 20b9954424
6 changed files with 15 additions and 15 deletions

View File

@@ -15,6 +15,8 @@ import SearchStore from 'stores/search_store.jsx';
import {handleNewPost, loadPosts, loadPostsBefore, loadPostsAfter} from 'actions/post_actions.jsx';
import {loadProfilesAndTeamMembersForDMSidebar} from 'actions/user_actions.jsx';
import {loadChannelsForCurrentUser} from 'actions/channel_actions.jsx';
import {stopPeriodicStatusUpdates} from 'actions/status_actions.jsx';
import * as WebsocketActions from 'actions/websocket_actions.jsx';
import Constants from 'utils/constants.jsx';
const ActionTypes = Constants.ActionTypes;
@@ -480,6 +482,8 @@ export function emitUserLoggedOutEvent(redirectTo = '/', shouldSignalLogout = tr
UserStore.clear();
TeamStore.clear();
newLocalizationSelected(global.window.mm_config.DefaultClientLocale);
stopPeriodicStatusUpdates();
WebsocketActions.close();
browserHistory.push(redirectTo);
},
() => {

View File

@@ -59,7 +59,6 @@ export function initialize() {
WebSocketClient.setEventCallback(handleEvent);
WebSocketClient.setFirstConnectCallback(handleFirstConnect);
WebSocketClient.setReconnectCallback(handleReconnect);
WebSocketClient.setCloseCallback(handleClose);
WebSocketClient.initialize(connUrl);
}
@@ -71,21 +70,18 @@ export function close() {
export function reconnect() {
close();
initialize();
handleReconnect();
}
function handleFirstConnect() {
if (Client.teamId) {
loadChannelsForCurrentUser();
loadPosts(ChannelStore.getCurrentId());
StatusActions.loadStatusesForChannelAndSidebar();
}
ErrorStore.clearLastError();
ErrorStore.emitChange();
}
function handleReconnect() {
if (Client.teamId) {
loadChannelsForCurrentUser();
loadPosts(ChannelStore.getCurrentId());
}
StatusActions.loadStatusesForChannelAndSidebar();
function handleFirstConnect() {
ErrorStore.clearLastError();
ErrorStore.emitChange();
}

View File

@@ -137,7 +137,7 @@ export default class AdminNavbarDropdown extends React.Component {
<li>
<a
href='#'
onClick={GlobalActions.emitUserLoggedOutEvent}
onClick={() => GlobalActions.emitUserLoggedOutEvent()}
>
<FormattedMessage
id='admin.nav.logout'

View File

@@ -203,7 +203,7 @@ export default class SelectTeam extends React.Component {
headerButton = (
<a
href='#'
onClick={GlobalActions.emitUserLoggedOutEvent}
onClick={() => GlobalActions.emitUserLoggedOutEvent()}
>
<span className='fa fa-chevron-left'/>
<FormattedMessage id='web.header.logout'/>

View File

@@ -477,7 +477,7 @@ export default class SidebarHeaderDropdown extends React.Component {
<li>
<a
href='#'
onClick={GlobalActions.emitUserLoggedOutEvent}
onClick={() => GlobalActions.emitUserLoggedOutEvent()}
>
<FormattedMessage
id='navbar_dropdown.logout'

View File

@@ -442,7 +442,7 @@ export default class SidebarRightMenu extends React.Component {
<li>
<a
href='#'
onClick={GlobalActions.emitUserLoggedOutEvent}
onClick={() => GlobalActions.emitUserLoggedOutEvent()}
>
<i className='icon fa fa-sign-out'/>
<FormattedMessage