diff options
Diffstat (limited to 'webapp/actions')
-rw-r--r-- | webapp/actions/global_actions.jsx | 7 | ||||
-rw-r--r-- | webapp/actions/websocket_actions.jsx | 17 |
2 files changed, 24 insertions, 0 deletions
diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx index 4baed20c3..aa51f6f62 100644 --- a/webapp/actions/global_actions.jsx +++ b/webapp/actions/global_actions.jsx @@ -288,6 +288,13 @@ export function showInviteMemberModal() { }); } +export function showLeaveTeamModal() { + AppDispatcher.handleViewAction({ + type: ActionTypes.TOGGLE_LEAVE_TEAM_MODAL, + value: true + }); +} + export function showRegisterAppModal() { AppDispatcher.handleViewAction({ type: ActionTypes.TOGGLE_REGISTER_APP_MODAL, diff --git a/webapp/actions/websocket_actions.jsx b/webapp/actions/websocket_actions.jsx index 17f84638d..9d9cf62b7 100644 --- a/webapp/actions/websocket_actions.jsx +++ b/webapp/actions/websocket_actions.jsx @@ -135,6 +135,10 @@ function handleMessage(msg) { handleNewUserEvent(); break; + case SocketEvents.LEAVE_TEAM: + handleLeaveTeamEvent(msg); + break; + case SocketEvents.USER_ADDED: handleUserAddedEvent(msg); break; @@ -219,6 +223,19 @@ function handleNewUserEvent() { AsyncClient.getChannelExtraInfo(); } +function handleLeaveTeamEvent(msg) { + if (UserStore.getCurrentId() === msg.user_id) { + TeamStore.removeTeamMember(msg.team_id); + + // if the are on the team begin removed redirect them to the root + if (TeamStore.getCurrentId() === msg.team_id) { + browserHistory.push('/'); + } + } else if (TeamStore.getCurrentId() === msg.team_id) { + GlobalActions.emitProfilesForDmList(); + } +} + function handleDirectAddedEvent(msg) { AsyncClient.getChannel(msg.channel_id); AsyncClient.getDirectProfiles(); |