Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const usersInChannel = usersInChannels[channel.id] || new Set([]);
// In case the channel is a DM and the profilesInChannel is not populated
if (!usersInChannel.size && channel.type === Constants.DM_CHANNEL) {
const userId = Utils.getUserIdFromChannelId(channel.name);
const user = getUser(curState, userId);
if (user) {
usersInChannel.add(userId);
}
}
for (const userId of usersInChannel) {
let userString = userSearchStrings[userId];
if (!userString) {
const user = getUser(curState, userId);
if (!user) {
continue;
}
const {nickname, username} = user;
userString = `${nickname}${username}${Utils.getFullName(user)}`;
userSearchStrings[userId] = userString;
}
searchString += userString;
}
}
return searchString.toLowerCase().includes(channelPrefixLower);
};
}
return (state, ownProps) => {
const channel = ownProps.channel || getChannel(state, {id: ownProps.channelId});
const member = getMyChannelMember(state, channel.id);
const currentUserId = getCurrentUserId(state);
const channelDraft = getDraftForChannel(state, channel.id);
let displayName = channel.display_name;
let isBot = false;
if (channel.type === General.DM_CHANNEL) {
if (ownProps.isSearchResult) {
isBot = Boolean(channel.isBot);
} else {
const teammateId = getUserIdFromChannelName(currentUserId, channel.name);
const teammate = getUser(state, teammateId);
const teammateNameDisplay = getTeammateNameDisplaySetting(state);
displayName = displayUsername(teammate, teammateNameDisplay, false);
if (teammate && teammate.is_bot) {
isBot = true;
}
}
}
const currentChannelId = getCurrentChannelId(state);
const isActive = ownProps.channelId === currentChannelId;
let shouldHideChannel = false;
if (
channel.name === General.DEFAULT_CHANNEL &&
!isActive &&
!ownProps.isFavorite &&
function mapStateToProps(state) {
const config = getConfig(state);
const license = getLicense(state);
const currentChannel = getCurrentChannel(state) || {};
const currentChannelCreator = getUser(state, currentChannel.creator_id);
const currentChannelCreatorName = currentChannelCreator && currentChannelCreator.username;
const currentChannelStats = getCurrentChannelStats(state);
const currentChannelMemberCount = currentChannelStats && currentChannelStats.member_count;
const currentChannelPinnedPostCount = currentChannelStats && currentChannelStats.pinnedpost_count;
let currentChannelGuestCount = (currentChannelStats && currentChannelStats.guest_count) || 0;
const currentChannelMember = getMyCurrentChannelMembership(state);
const currentUserId = getCurrentUserId(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);
let canManageUsers = currentChannel.hasOwnProperty('id') ? canManageChannelMembers(state) : false;
if (currentChannel.group_constrained) {
canManageUsers = false;
}
const currentUser = getUser(state, currentUserId);
getProfile(userId) {
return Selectors.getUser(store.getState(), userId);
}
function mapStateToProps(state, ownProps) {
return {
isMyUser: getCurrentUserId(state) === ownProps.id,
theme: getTheme(state),
user: getUser(state, ownProps.id),
teammateNameDisplay: getTeammateNameDisplaySetting(state),
isLandscape: isLandscape(state),
};
}
export function getUserById(userId) {
const state = store.getState();
return getUser(state, userId);
}
(state, channel) => getUser(state, getOtherUserIdForDm(state, channel)),
(otherUser) => {
return function mapStateToProps(state, ownProps) {
const currentChannel = getChannel(state, {id: ownProps.channelId}) || {};
let currentChannelMembers;
let creator;
if (currentChannel) {
if (currentChannel.type === General.DM_CHANNEL) {
currentChannelMembers = getChannelMembersForDm(state, currentChannel);
} else {
currentChannelMembers = getChannelMembers(state, currentChannel);
}
creator = getUser(state, currentChannel.creator_id);
}
return {
creator,
currentChannel,
currentChannelMembers,
theme: getTheme(state),
isLandscape: isLandscape(state),
};
};
}
function mapStateToProps(state, ownProps) {
const config = getConfig(state);
return {
enablePostIconOverride: config.EnablePostIconOverride === 'true',
hasImageProxy: config.HasImageProxy === 'true',
status: getStatusForUserId(state, ownProps.userId),
user: getUser(state, ownProps.userId),
};
}