How to use the mattermost-redux/selectors/entities/channels.getChannel 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 / actions / websocket_actions.jsx View on Github external
dispatch({
            type: ChannelTypes.LEAVE_CHANNEL,
            data: {id: msg.data.channel_id, user_id: msg.broadcast.user_id},
        });
    } else if (msg.broadcast.channel_id === currentChannel.id) {
        dispatch(getChannelStats(currentChannel.id));
        dispatch({
            type: UserTypes.RECEIVED_PROFILE_NOT_IN_CHANNEL,
            data: {id: msg.broadcast.channel_id, user_id: msg.data.user_id},
        });
    }

    const channelId = msg.broadcast.channel_id || msg.data.channel_id;
    const userId = msg.broadcast.user_id || msg.data.user_id;
    const channel = getChannel(state, channelId);
    if (channel && !haveISystemPermission(state, {permission: Permissions.VIEW_MEMBERS}) && !haveITeamPermission(state, {permission: Permissions.VIEW_MEMBERS, team: channel.team_id})) {
        dispatch(batchActions([
            {
                type: UserTypes.RECEIVED_PROFILE_NOT_IN_TEAM,
                data: {id: channel.team_id, user_id: userId},
            },
            {
                type: TeamTypes.REMOVE_MEMBER_FROM_TEAM,
                data: {team_id: channel.team_id, user_id: userId},
            },
        ]));
    }
}
github mattermost / mattermost-webapp / actions / websocket_actions.jsx View on Github external
function handleChannelConvertedEvent(msg) {
    const channelId = msg.data.channel_id;
    if (channelId) {
        const channel = getChannel(getState(), channelId);
        if (channel) {
            dispatch({
                type: ChannelTypes.RECEIVED_CHANNEL,
                data: {...channel, type: General.PRIVATE_CHANNEL},
            });
        }
    }
}
github mattermost / mattermost-webapp / components / post_view / reaction / index.js View on Github external
const me = getCurrentUser(state);

        const profiles = getProfilesForReactions(state, ownProps.reactions);
        let emoji;
        if (Emoji.EmojiIndicesByAlias.has(ownProps.emojiName)) {
            emoji = Emoji.Emojis[Emoji.EmojiIndicesByAlias.get(ownProps.emojiName)];
        } else {
            const emojis = getCustomEmojisByName(state);
            emoji = emojis.get(ownProps.emojiName);
        }

        let emojiImageUrl = '';
        if (emoji) {
            emojiImageUrl = getEmojiImageUrl(emoji);
        }
        const channel = getChannel(state, ownProps.post.channel_id) || {};
        const channelIsArchived = channel.delete_at !== 0;
        const teamId = channel.team_id;

        let canAddReaction = false;
        let canRemoveReaction = false;

        if (!channelIsArchived) {
            canAddReaction = checkReactionAction(state, teamId, ownProps.post.channel_id, channel.name, config, license, me, Permissions.REMOVE_REACTION);
            canRemoveReaction = checkReactionAction(state, teamId, ownProps.post.channel_id, channel.name, config, license, me, Permissions.ADD_REACTION);
        }

        return {
            profiles,
            otherUsersCount: ownProps.reactions.length - profiles.length,
            currentUserId: getCurrentUserId(state),
            reactionCount: ownProps.reactions.length,
github mattermost / mattermost-webapp / components / search_results / index.jsx View on Github external
results.forEach((post) => {
                if (!post) {
                    return;
                }

                const channel = getChannel(state, post.channel_id);
                if (channel && channel.delete_at !== 0 && !viewArchivedChannels) {
                    return;
                }

                posts.push(post);
            });
        }
github mattermost / mattermost-webapp / components / rhs_root_post / index.js View on Github external
function mapStateToProps(state, ownProps) {
    const getReactionsForPost = makeGetReactionsForPost();
    const getDisplayName = makeGetDisplayName();

    const config = getConfig(state);
    const enableEmojiPicker = config.EnableEmojiPicker === 'true';
    const enablePostUsernameOverride = config.EnablePostUsernameOverride === 'true';
    const teamId = ownProps.teamId || getCurrentTeamId(state);
    const channel = getChannel(state, ownProps.post.channel_id) || {};

    return {
        author: getDisplayName(state, ownProps.post.user_id),
        reactions: getReactionsForPost(state, ownProps.post.id),
        enableEmojiPicker,
        enablePostUsernameOverride,
        isEmbedVisible: isEmbedVisible(state, ownProps.post.id),
        isReadOnly: isChannelReadOnlyById(state, ownProps.post.channel_id),
        teamId,
        pluginPostTypes: state.plugins.postTypes,
        channelIsArchived: channel.delete_at !== 0,
        channelType: channel.type,
        channelDisplayName: channel.display_name,
        isFlagged: get(state, Preferences.CATEGORY_FLAGGED_POST, ownProps.post.id, null) != null,
        compactDisplay: get(state, Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.MESSAGE_DISPLAY, Preferences.MESSAGE_DISPLAY_DEFAULT) === Preferences.MESSAGE_DISPLAY_COMPACT,
    };
github mattermost / mattermost-mobile / app / screens / notification / index.js View on Github external
function mapStateToProps(state, ownProps) {
    const {data} = ownProps.notification;
    const {deviceWidth} = getDimensions(state);

    let user;
    if (data.sender_id) {
        user = getUser(state, data.sender_id);
    }

    let channel;
    if (data.channel_id) {
        channel = getChannel(state, data.channel_id);
    }

    return {
        config: state.entities.general.config,
        channel,
        deviceWidth,
        user,
        teammateNameDisplay: getTeammateNameDisplaySetting(state),
        theme: getTheme(state),
    };
}
github mattermost / mattermost-webapp / components / post_view / post_add_channel_member / index.js View on Github external
function mapStateToProps(state, ownProps) {
    const post = getPost(state, ownProps.postId) || {};
    let channelType = '';
    if (post && post.channel_id) {
        const channel = getChannel(state, post.channel_id);
        if (channel && channel.type) {
            channelType = channel.type;
        }
    }

    return {
        ...ownProps,
        channelType,
        currentUser: getCurrentUser(state),
        post,
    };
}
github mattermost / mattermost-mobile / app / actions / views / channel.js View on Github external
},
            setChannelLoading(false),
            {
                type: ViewTypes.SET_LAST_CHANNEL_FOR_TEAM,
                teamId: currentTeamId,
                channelId,
            },
        ];

        let markPreviousChannelId;
        if (!fromPushNotification && !sameChannel) {
            markPreviousChannelId = currentChannelId;
            actions.push({
                type: ViewTypes.SELECT_CHANNEL_WITH_MEMBER,
                data: currentChannelId,
                channel: getChannel(state, currentChannelId),
                member: getMyChannelMember(state, currentChannelId),
            });
        }

        if (!fromPushNotification) {
            actions.push({
                type: ViewTypes.SELECT_CHANNEL_WITH_MEMBER,
                data: channelId,
                channel,
                member,
            });
        }

        dispatch(batchActions(actions));

        dispatch(markChannelViewedAndRead(channelId, markPreviousChannelId));
github mattermost / mattermost-webapp / utils / post_utils.jsx View on Github external
export function canEditPost(post) {
    const state = store.getState();
    const license = getLicense(state);
    const config = getConfig(state);
    const channel = getChannel(state, post.channel_id);
    const userId = getCurrentUserId(state);
    return canEditPostRedux(state, config, license, channel && channel.team_id, channel && channel.id, userId, post);
}
github mattermost / mattermost-mobile / app / components / autocomplete / channel_mention_item / index.js View on Github external
function mapStateToProps(state, ownProps) {
    const channel = getChannel(state, ownProps.channelId);
    let displayName = getChannelNameForSearchAutocomplete(state, ownProps.channelId);

    let isBot = false;
    let isGuest = false;
    if (channel?.type === General.DM_CHANNEL) {
        const teammate = getUser(state, channel.teammate_id);
        if (teammate) {
            displayName = teammate.username;
            isBot = teammate.is_bot || false;
            isGuest = isGuestUser(teammate) || false;
        }
    }

    return {
        displayName,
        name: channel?.name,