diff options
Diffstat (limited to 'webapp/action_creators/websocket_actions.jsx')
-rw-r--r-- | webapp/action_creators/websocket_actions.jsx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/webapp/action_creators/websocket_actions.jsx b/webapp/action_creators/websocket_actions.jsx index a1368ac99..83a000f6d 100644 --- a/webapp/action_creators/websocket_actions.jsx +++ b/webapp/action_creators/websocket_actions.jsx @@ -18,6 +18,8 @@ import * as GlobalActions from 'action_creators/global_actions.jsx'; import Constants from 'utils/constants.jsx'; const SocketEvents = Constants.SocketEvents; +import {browserHistory} from 'react-router'; + const MAX_WEBSOCKET_FAILS = 7; const WEBSOCKET_RETRY_TIME = 3000; @@ -135,6 +137,10 @@ function handleMessage(msg) { handleChannelViewedEvent(msg); break; + case SocketEvents.CHANNEL_DELETED: + handleChannelDeletedEvent(msg); + break; + case SocketEvents.PREFERENCE_CHANGED: handlePreferenceChangedEvent(msg); break; @@ -234,6 +240,15 @@ function handleChannelViewedEvent(msg) { } } +function handleChannelDeletedEvent(msg) { + if (ChannelStore.getCurrentId() === msg.channel_id) { + const teamUrl = TeamStore.getCurrentTeamRelativeUrl(); + browserHistory.push(teamUrl + '/channels/' + Constants.DEFAULT_CHANNEL); + } else { + AsyncClient.getChannels(); + } +} + function handlePreferenceChangedEvent(msg) { const preference = JSON.parse(msg.props.preference); GlobalActions.emitPreferenceChangedEvent(preference); |