diff --git a/service/actions/websocket.js b/service/actions/websocket.js index 22c6995ab..4411f7131 100644 --- a/service/actions/websocket.js +++ b/service/actions/websocket.js @@ -266,6 +266,10 @@ function handleUserRemovedEvent(msg, dispatch, getState) { if (msg.broadcast.user_id === users.currentId && teamId) { fetchMyChannelsAndMembers(teamId)(dispatch, getState); + dispatch({ + type: ChannelTypes.LEAVE_CHANNEL, + data: msg.data.channel_id + }, getState); } else if (msg.broadcast.channel_id === channels.currentId) { getChannelStats(teamId, channels.currentId)(dispatch, getState); } diff --git a/service/selectors/entities/channels.js b/service/selectors/entities/channels.js index 05f27db29..89f40c9c7 100644 --- a/service/selectors/entities/channels.js +++ b/service/selectors/entities/channels.js @@ -52,15 +52,16 @@ export const getChannelsOnCurrentTeam = createSelector( export const getChannelsByCategory = createSelector( getCurrentChannelId, getChannelsOnCurrentTeam, + (state) => state.entities.channels.myMembers, (state) => state.entities.users, (state) => state.entities.preferences.myPreferences, (state) => state.entities.teams, - (currentChannelId, channels, usersState, myPreferences, teamsState) => { + (currentChannelId, channels, myMembers, usersState, myPreferences, teamsState) => { const allChannels = channels.map((c) => { const channel = {...c}; channel.isCurrent = c.id === currentChannelId; return channel; - }); + }).filter((c) => myMembers.hasOwnProperty(c.id)); return buildDisplayableChannelList(usersState, teamsState, allChannels, myPreferences); }