Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function mapStateToProps(state) {
const config = getConfig(state);
const currentChannel = getCurrentChannel(state);
const currentTeammate = currentChannel && currentChannel.teammate_id && getCurrentChannel(state, currentChannel.teammate_id);
const currentTeam = getCurrentTeam(state);
const canCreatePublicChannel = haveITeamPermission(state, {team: currentTeam.id, permission: Permissions.CREATE_PUBLIC_CHANNEL});
const canCreatePrivateChannel = haveITeamPermission(state, {team: currentTeam.id, permission: Permissions.CREATE_PRIVATE_CHANNEL});
const sidebarPrefs = getSidebarPreferences(state);
const lastUnreadChannel = state.views.channel.keepChannelIdAsUnread;
const unreadChannelIds = getSortedUnreadChannelIds(state, lastUnreadChannel);
const orderedChannelIds = getOrderedChannelIds(
state,
lastUnreadChannel,
sidebarPrefs.grouping,
sidebarPrefs.sorting,
sidebarPrefs.unreads_at_top === 'true',
sidebarPrefs.favorite_at_top === 'true',
return (state) => {
const currentChannel = getCurrentChannel(state);
let currentChannelMembers = [];
if (currentChannel.id) {
currentChannelMembers = getChannelMembers(state, currentChannel.id, true);
}
const canManageUsers = canManageChannelMembers(state) && !currentChannel.group_constrained;
return {
canManageUsers,
currentChannelId: currentChannel.id,
currentChannelMembers,
currentUserId: state.entities.users.currentUserId,
theme: getTheme(state),
isLandscape: isLandscape(state),
};
};
function handleUserRemovedEvent(msg) {
const state = getState();
const currentChannel = getCurrentChannel(state) || {};
const currentUserId = getCurrentUserId(state);
if (msg.broadcast.user_id === currentUserId) {
dispatch(loadChannelsForCurrentUser());
if (msg.data.channel_id === currentChannel.id) {
GlobalActions.emitCloseRightHandSide();
if (msg.data.remover_id === msg.broadcast.user_id) {
browserHistory.push(getCurrentRelativeTeamUrl(state));
} else {
const user = getUser(state, msg.data.remover_id) || {};
dispatch(openModal({
modalId: ModalIdentifiers.REMOVED_FROM_CHANNEL,
dialogType: RemovedFromChannelModal,
function mapStateToProps(state) {
const config = getConfig(state);
const license = getLicense(state);
const currentChannel = getCurrentChannel(state);
const currentTeam = getCurrentTeam(state);
const isLicensed = license.IsLicensed === 'true';
const customBrand = license.CustomBrand === 'true';
const enableCustomBrand = config.EnableCustomBrand === 'true';
const customDescriptionText = config.CustomDescriptionText;
const siteName = config.SiteName;
return {
currentChannel,
currentTeam,
isLicensed,
customBrand,
enableCustomBrand,
customDescriptionText,
siteName,
const mapStateToProps = (state) => ({
visible: isRootModalVisible(state),
files: getLoadedFiles(state),
currentRequest: (getLoadedFiles(state) || empty).Request,
currentUserId: getCurrentUserId(state),
currentChannelName: (getCurrentChannel(state) || empty).display_name,
error: getError(state)
});
function mapStateToProps(state) {
return {
canManageUsers: canManageChannelMembers(state),
currentChannel: getCurrentChannel(state),
theme: getTheme(state)
};
}
function mapStateToProps(state) {
const currentChannelMemberCount = getCurrentChannelStats(state) && getCurrentChannelStats(state).member_count;
return {
theme: getTheme(state),
currentChannel: getCurrentChannel(state),
currentChannelMembers: getProfilesInCurrentChannel(state),
currentChannelMemberCount,
currentUserId: state.entities.users.currentUserId,
currentTeam: getCurrentTeam(state),
preferences: getMyPreferences(state),
requestStatus: state.requests.users.getProfilesInChannel.status,
searchRequestStatus: state.requests.users.searchProfiles.status,
removeMembersStatus: state.requests.channels.removeChannelMember.status,
canManageUsers: canManageChannelMembers(state)
};
}
function mapStateToProps(state) {
const config = getConfig(state);
let channel = getCurrentChannel(state);
if (channel && channel.delete_at !== 0) {
channel = getDefaultChannel(state);
}
return {
channelId: channel?.id,
channels: getAllChannels(state),
currentUserId: getCurrentUserId(state),
maxFileSize: getAllowedServerMaxFileSize(config),
teamId: getCurrentTeamId(state),
};
}
function mapStateToProps(state, ownProps) {
const userId = ownProps.userId;
const team = getCurrentTeam(state);
const teamMember = getTeamMember(state, team.id, userId);
let isTeamAdmin = false;
if (teamMember && teamMember.scheme_admin) {
isTeamAdmin = true;
}
const selectedPost = getSelectedPost(state);
const currentChannel = getCurrentChannel(state);
let channelId;
if (selectedPost.exists === false) {
channelId = currentChannel.id;
} else {
channelId = selectedPost.channel_id;
}
const channelMember = getChannelMembersInChannels(state)[channelId][userId];
let isChannelAdmin = false;
if (getRhsState(state) !== 'search' && channelMember != null && channelMember.scheme_admin) {
isChannelAdmin = true;
}
return {