How to use the mattermost-redux/selectors/entities/users.getUser function in mattermost-redux

To help you get started, we’ve selected a few mattermost-redux examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mattermost / mattermost-webapp / components / suggestion / switch_channel_provider.jsx View on Github external
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);
    };
}
github mattermost / mattermost-mobile / app / components / sidebars / main / channels_list / channel_item / index.js View on Github external
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 &&
github mattermost / mattermost-mobile / app / screens / channel_info / index.js View on Github external
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);
github mattermost / mattermost-webapp / stores / user_store.jsx View on Github external
getProfile(userId) {
        return Selectors.getUser(store.getState(), userId);
    }
github mattermost / mattermost-mobile / app / components / custom_list / user_list_row / index.js View on Github external
function mapStateToProps(state, ownProps) {
    return {
        isMyUser: getCurrentUserId(state) === ownProps.id,
        theme: getTheme(state),
        user: getUser(state, ownProps.id),
        teammateNameDisplay: getTeammateNameDisplaySetting(state),
        isLandscape: isLandscape(state),
    };
}
github mattermost / mattermost-webapp / utils / utils.jsx View on Github external
export function getUserById(userId) {
    const state = store.getState();
    return getUser(state, userId);
}
github mattermost / mattermost-mobile / app / selectors / channel.js View on Github external
    (state, channel) => getUser(state, getOtherUserIdForDm(state, channel)),
    (otherUser) => {
github mattermost / mattermost-mobile / app / components / channel_intro / index.js View on Github external
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),
        };
    };
}
github mattermost / mattermost-webapp / components / post_profile_picture / index.jsx View on Github external
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),
    };
}