UNPKG

mattermost-redux

Version:

Common code (API client, Redux stores, logic, utility functions) for building a Mattermost client

55 lines (54 loc) 2.52 kB
"use strict"; // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. Object.defineProperty(exports, "__esModule", { value: true }); exports.getContentFlaggingTeam = exports.getContentFlaggingChannel = exports.getFlaggedPost = exports.postContentFlaggingValues = exports.contentFlaggingFields = exports.contentFlaggingConfig = exports.contentFlaggingFeatureEnabled = void 0; const general_1 = require("mattermost-redux/selectors/entities/general"); const contentFlaggingFeatureEnabled = (state) => { const featureFlagEnabled = (0, general_1.getFeatureFlagValue)(state, 'ContentFlagging') === 'true'; const featureEnabled = state.entities.general.config.ContentFlaggingEnabled === 'true'; return featureFlagEnabled && featureEnabled; }; exports.contentFlaggingFeatureEnabled = contentFlaggingFeatureEnabled; const contentFlaggingConfig = (state) => { const config = state.entities.contentFlagging.settings; return (config && Object.keys(config).length) ? config : undefined; }; exports.contentFlaggingConfig = contentFlaggingConfig; const contentFlaggingFields = (state) => { const fields = state.entities.contentFlagging.fields; return (fields && Object.keys(fields).length) ? fields : undefined; }; exports.contentFlaggingFields = contentFlaggingFields; const postContentFlaggingValues = (state, postId) => { const values = state.entities.contentFlagging.postValues || {}; return values[postId]; }; exports.postContentFlaggingValues = postContentFlaggingValues; const getFlaggedPost = (state, flaggedPostId) => { return state.entities.contentFlagging.flaggedPosts?.[flaggedPostId]; }; exports.getFlaggedPost = getFlaggedPost; const getContentFlaggingChannel = (state, { channelId }) => { // Return channel from the regular channel store if available, else get it from the content flagging store if (!channelId) { return undefined; } const channel = state.entities.channels.channels[channelId]; if (channel) { return channel; } return state.entities.contentFlagging.channels?.[channelId]; }; exports.getContentFlaggingChannel = getContentFlaggingChannel; const getContentFlaggingTeam = (state, { teamId }) => { if (!teamId) { return undefined; } const team = state.entities.teams.teams[teamId]; if (team) { return team; } return state.entities.contentFlagging.teams?.[teamId]; }; exports.getContentFlaggingTeam = getContentFlaggingTeam;