Fix unhandled exception when current user is not defined (#4567)
This commit is contained in:
parent
c2be31c644
commit
934dbfde17
3 changed files with 17 additions and 6 deletions
|
|
@ -68,12 +68,19 @@ export function mapStateToProps(state, ownProps) {
|
|||
);
|
||||
}
|
||||
|
||||
const channelId = ownProps.channelId || (currentChannel ? currentChannel.id : '');
|
||||
|
||||
let channelIsReadOnly = false;
|
||||
if (currentUserId && channelId) {
|
||||
channelIsReadOnly = isCurrentChannelReadOnly(state) || false;
|
||||
}
|
||||
|
||||
return {
|
||||
canPost,
|
||||
channelDisplayName: state.views.channel.displayName || (currentChannel ? currentChannel.display_name : ''),
|
||||
channelId: ownProps.channelId || (currentChannel ? currentChannel.id : ''),
|
||||
channelId,
|
||||
channelIsArchived: ownProps.channelIsArchived || (currentChannel ? currentChannel.delete_at !== 0 : false),
|
||||
channelIsReadOnly: isCurrentChannelReadOnly(state) || false,
|
||||
channelIsReadOnly,
|
||||
currentUserId,
|
||||
deactivatedChannel,
|
||||
enableConfirmNotificationsToChannel,
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ export function getUserByEmail(state: GlobalState, email: $Email<UserProfile>):
|
|||
export const isCurrentUserSystemAdmin: (a: GlobalState) => boolean = createSelector(
|
||||
getCurrentUser,
|
||||
(user) => {
|
||||
const roles = user.roles || '';
|
||||
const roles = user?.roles || '';
|
||||
return isSystemAdmin(roles);
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -67,9 +67,9 @@ function mapStateToProps(state) {
|
|||
const favoriteChannels = getSortedFavoriteChannelIds(state);
|
||||
const isCurrent = currentChannel.id === state.entities.channels.currentChannelId;
|
||||
const isFavorite = favoriteChannels && favoriteChannels.indexOf(currentChannel.id) > -1;
|
||||
const roles = getCurrentUserRoles(state);
|
||||
const roles = getCurrentUserRoles(state) || '';
|
||||
const {serverVersion} = state.entities.general;
|
||||
let canManageUsers = currentChannel.hasOwnProperty('id') ? canManageChannelMembers(state) : false;
|
||||
let canManageUsers = currentChannel.id ? canManageChannelMembers(state) : false;
|
||||
if (currentChannel.group_constrained) {
|
||||
canManageUsers = false;
|
||||
}
|
||||
|
|
@ -96,7 +96,11 @@ function mapStateToProps(state) {
|
|||
const isChannelAdmin = checkIsChannelAdmin(roles);
|
||||
const isSystemAdmin = checkIsSystemAdmin(roles);
|
||||
|
||||
const channelIsReadOnly = isCurrentChannelReadOnly(state);
|
||||
let channelIsReadOnly = false;
|
||||
if (currentUserId && currentChannel.id) {
|
||||
channelIsReadOnly = isCurrentChannelReadOnly(state) || false;
|
||||
}
|
||||
|
||||
const canEditChannel = !channelIsReadOnly && showManagementOptions(state, config, license, currentChannel, isAdmin, isSystemAdmin, isChannelAdmin);
|
||||
const viewArchivedChannels = config.ExperimentalViewArchivedChannels === 'true';
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue