Skip to content

Commit

Permalink
Merge branch 'rm/373624' into 'master'
Browse files Browse the repository at this point in the history
fix: handle case where channel is undefined for channel header dropdown

See merge request kchat/webapp!968
  • Loading branch information
antonbuks committed Nov 25, 2024
2 parents fa30eac + 6bd80ba commit 11f97e5
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions webapp/channels/src/components/channel_header_dropdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,29 @@ const getTeammateStatus = createSelector(
const mapStateToProps = (state: GlobalState) => {
const user = getCurrentUser(state);
const channel = getCurrentChannel(state);

// Handle the case where channel is undefined (e.g the user leave the channel)
const channelId = channel?.id || '';
const channelName = channel?.name || '';
const isDefault = channel ? isCurrentChannelDefault(state) : false;
const isFavorite = channel ? isCurrentChannelFavorite(state) : false;
const isMuted = channel ? isCurrentChannelMuted(state) : false;
const isArchived = channel ? isCurrentChannelArchived(state) : false;
const hasCall = channel ? getConferenceByChannelId(state, channelId) != null : false;

return {
user,
channel,
dmUserId: getUserIdFromChannelName(user.id, channel.name),
isDefault: isCurrentChannelDefault(state),
isFavorite: isCurrentChannelFavorite(state),
isMuted: isCurrentChannelMuted(state),
dmUserId: getUserIdFromChannelName(user.id, channelName),
isDefault,
isFavorite,
isMuted,
isReadonly: false,
isArchived: isCurrentChannelArchived(state),
isArchived,
penultimateViewedChannelName: getPenultimateViewedChannelName(state) || getRedirectChannelNameForTeam(state, getCurrentTeamId(state)),
pluginMenuItems: getChannelHeaderMenuPluginComponents(state),
isLicensedForLDAPGroups: state.entities.general.license.LDAPGroups === 'true',
hasCall: getConferenceByChannelId(state, channel.id) != null,
hasCall,
};
};

Expand Down

0 comments on commit 11f97e5

Please sign in to comment.