mattermost-redux
Version:
Common code (API client, Redux stores, logic, utility functions) for building a Mattermost client
47 lines (46 loc) • 2.01 kB
JavaScript
;
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.getIsUserStatusesConfigEnabled = exports.getMyCurrentChannelMembership = void 0;
exports.getCurrentChannelId = getCurrentChannelId;
exports.getMyChannelMemberships = getMyChannelMemberships;
exports.getMembersInChannel = getMembersInChannel;
exports.getMembersInTeam = getMembersInTeam;
exports.getCurrentUser = getCurrentUser;
exports.getCurrentUserEmail = getCurrentUserEmail;
exports.getCurrentUserId = getCurrentUserId;
exports.getUsers = getUsers;
const create_selector_1 = require("mattermost-redux/selectors/create_selector");
// Channels
function getCurrentChannelId(state) {
return state.entities.channels.currentChannelId;
}
function getMyChannelMemberships(state) {
return state.entities.channels.myMembers;
}
exports.getMyCurrentChannelMembership = (0, create_selector_1.createSelector)('getMyCurrentChannelMembership', getCurrentChannelId, getMyChannelMemberships, (currentChannelId, channelMemberships) => {
return channelMemberships[currentChannelId];
});
function getMembersInChannel(state, channelId) {
return state.entities.channels?.membersInChannel?.[channelId] || {};
}
// Teams
function getMembersInTeam(state, teamId) {
return state.entities.teams?.membersInTeam?.[teamId] || {};
}
// Users
function getCurrentUser(state) {
return state.entities.users.profiles[getCurrentUserId(state)];
}
function getCurrentUserEmail(state) {
return getCurrentUser(state)?.email;
}
function getCurrentUserId(state) {
return state.entities.users.currentUserId;
}
function getUsers(state) {
return state.entities.users.profiles;
}
// Config
exports.getIsUserStatusesConfigEnabled = (0, create_selector_1.createSelector)('getIsUserStatusesConfigEnabled', (state) => state.entities.general.config.EnableUserStatuses, (EnableUserStatuses) => EnableUserStatuses !== 'false');