How to use the mattermost-redux/selectors/entities/users.getCurrentUserId 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
function handleChannelViewedEvent(msg) {
    // Useful for when multiple devices have the app open to different channels
    if ((!window.isActive || getCurrentChannelId(getState()) !== msg.data.channel_id) &&
        getCurrentUserId(getState()) === msg.broadcast.user_id) {
        dispatch(markChannelAsRead(msg.data.channel_id, '', false));
    }
}
github mattermost / mattermost-webapp / actions / websocket_actions.jsx View on Github external
function handleChannelViewedEvent(msg) {
    // Useful for when multiple devices have the app open to different channels
    if ((!window.isActive || getCurrentChannelId(getState()) !== msg.data.channel_id) &&
        getCurrentUserId(getState()) === msg.broadcast.user_id) {
        dispatch(markChannelAsRead(msg.data.channel_id, '', false));
    }
}
github mattermost / mattermost-webapp / components / root / switch / index.js View on Github external
function defaultRoute(state) {
    const userId = getCurrentUserId(state);

    if (!userId) {
        return '/login';
    }

    const teamId = LocalStorageStore.getPreviousTeamId(userId);
    const locale = getCurrentLocale(state);

    let team = getTeam(state, teamId);
    const myMember = getMyTeamMember(state, teamId);

    if (!team || !myMember || !myMember.team_id) {
        team = null;
        let myTeams = getMyTeams(state);

        if (myTeams.length > 0) {
github mattermost / mattermost-mobile / app / screens / channel_peek / index.js View on Github external
function mapStateToProps(state, ownProps) {
    const channelId = ownProps.channelId;
    const myMember = getMyChannelMember(state, channelId);

    return {
        channelId,
        currentUserId: getCurrentUserId(state),
        postIds: getPostIdsInChannel(state, channelId),
        lastViewedAt: myMember && myMember.last_viewed_at,
        theme: getTheme(state),
    };
}
github mattermost / mattermost-mobile / app / screens / user_profile / index.js View on Github external
const config = getConfig(state);
    const {createChannel: createChannelRequest} = state.requests.channels;
    const militaryTime = getBool(state, Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time');
    const enableTimezone = isTimezoneEnabled(state);

    return {
        config,
        createChannelRequest,
        currentDisplayName: state.views.channel.displayName,
        user: state.entities.users.profiles[ownProps.userId],
        bot: getBotAccounts(state)[ownProps.userId],
        teammateNameDisplay: getTeammateNameDisplaySetting(state),
        enableTimezone,
        militaryTime,
        theme: getTheme(state),
        isMyUser: getCurrentUserId(state) === ownProps.userId,
        isLandscape: isLandscape(state),
    };
}
github mattermost / mattermost-webapp / components / do_verify_email / index.js View on Github external
function mapStateToProps(state) {
    const config = getConfig(state);
    const siteName = config.SiteName;
    return {
        isLoggedIn: Boolean(getCurrentUserId(state)),
        siteName,
        user: getCurrentUser(state),
    };
}
github mattermost / mattermost-webapp / components / post_view / post_attachment_opengraph / index.js View on Github external
function mapStateToProps(state, ownProps) {
    const config = getConfig(state);

    return {
        currentUserId: getCurrentUserId(state),
        enableLinkPreviews: config.EnableLinkPreviews === 'true',
        openGraphData: getOpenGraphMetadataForUrl(state, ownProps.postId, ownProps.link),
        previewEnabled: getBool(state, Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.LINK_PREVIEW_DISPLAY, true),
    };
}
github mattermost / mattermost-mobile / app / components / reactions / index.js View on Github external
return function mapStateToProps(state, ownProps) {
        const post = getPost(state, ownProps.postId);
        const channelId = post ? post.channel_id : '';
        const channel = getChannel(state, channelId) || {};
        const teamId = channel.team_id;
        const channelIsArchived = channel.delete_at !== 0;
        const channelIsReadOnly = isChannelReadOnlyById(state, channelId);

        const currentUserId = getCurrentUserId(state);
        const reactions = getReactionsForPostSelector(state, ownProps.postId);

        let canAddReaction = true;
        let canRemoveReaction = true;
        let canAddMoreReactions = true;
        if (channelIsArchived || channelIsReadOnly) {
            canAddReaction = false;
            canRemoveReaction = false;
            canAddMoreReactions = false;
        } else if (hasNewPermissions(state)) {
            canAddReaction = haveIChannelPermission(state, {
                team: teamId,
                channel: channelId,
                permission: Permissions.ADD_REACTION,
            });
            canAddMoreReactions = Object.values(reactions).length < MAX_ALLOWED_REACTIONS;
github mattermost / mattermost-mobile / app / components / post_textbox / post_textbox_container.js View on Github external
function mapStateToProps(state, ownProps) {
    return {
        ...ownProps,
        channelIsLoading: state.views.channel.loading,
        currentUserId: getCurrentUserId(state),
        typing: getUsersTyping(state),
        theme: getTheme(state),
        uploadFileRequestStatus: state.requests.files.uploadFiles.status
    };
}
github mattermost / mattermost-webapp / actions / user_actions.jsx View on Github external
export async function loadProfilesForDM() {
    const state = getState();
    const channels = getMyChannels(state);
    const newPreferences = [];
    const profilesToLoad = [];
    const profileIds = [];
    const currentUserId = Selectors.getCurrentUserId(state);

    for (let i = 0; i < channels.length; i++) {
        const channel = channels[i];
        if (channel.type !== Constants.DM_CHANNEL) {
            continue;
        }

        const teammateId = channel.name.replace(currentUserId, '').replace('__', '');
        const isVisible = getBool(state, Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, teammateId);

        if (!isVisible) {
            const member = getMyChannelMember(state, channel.id);
            if (!member || member.mention_count === 0) {
                continue;
            }