From fb4d72bd8a3a9b533571e42cfb1b7e2d1702f6be Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Tue, 9 May 2017 05:24:53 -0500 Subject: Fix getting removed from channel or team (#6357) --- webapp/actions/websocket_actions.jsx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/webapp/actions/websocket_actions.jsx b/webapp/actions/websocket_actions.jsx index 4d2b5a2b5..f85c32479 100644 --- a/webapp/actions/websocket_actions.jsx +++ b/webapp/actions/websocket_actions.jsx @@ -34,9 +34,10 @@ import {browserHistory} from 'react-router/es6'; import store from 'stores/redux_store.jsx'; const dispatch = store.dispatch; const getState = store.getState; +import {batchActions} from 'redux-batched-actions'; import {viewChannel, getChannelAndMyMember, getChannelStats} from 'mattermost-redux/actions/channels'; import {setServerVersion} from 'mattermost-redux/actions/general'; -import {ChannelTypes} from 'mattermost-redux/action_types'; +import {ChannelTypes, TeamTypes, UserTypes} from 'mattermost-redux/action_types'; const MAX_WEBSOCKET_FAILS = 7; @@ -294,6 +295,18 @@ function handleLeaveTeamEvent(msg) { GlobalActions.redirectUserToDefaultTeam(); } } + + dispatch(batchActions([ + { + type: UserTypes.RECEIVED_PROFILE_NOT_IN_TEAM, + data: {user_id: msg.data.user_id}, + id: msg.data.team_id + }, + { + type: TeamTypes.REMOVE_MEMBER_FROM_TEAM, + data: {team_id: msg.data.team_id, user_id: msg.data.user_id} + } + ])); } else { UserStore.removeProfileFromTeam(msg.data.team_id, msg.data.user_id); TeamStore.removeMemberInTeam(msg.data.team_id, msg.data.user_id); @@ -334,6 +347,11 @@ function handleUserRemovedEvent(msg) { BrowserStore.setItem('channel-removed-state', sentState); $('#removed_from_channel').modal('show'); } + + dispatch({ + type: ChannelTypes.LEAVE_CHANNEL, + data: {id: msg.data.channel_id, user_id: msg.broadcast.user_id} + }); } else if (ChannelStore.getCurrentId() === msg.broadcast.channel_id) { getChannelStats(ChannelStore.getCurrentId())(dispatch, getState); } -- cgit v1.2.3-1-g7c22