mattermost-redux
Version:
Common code (API client, Redux stores, logic, utility functions) for building a Mattermost client
48 lines (47 loc) • 1.55 kB
JavaScript
;
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
Object.defineProperty(exports, "__esModule", { value: true });
const redux_1 = require("redux");
const action_types_1 = require("mattermost-redux/action_types");
function pending(state = new Set(), action) {
switch (action.type) {
case action_types_1.RoleTypes.SET_PENDING_ROLES:
return action.data;
case action_types_1.UserTypes.LOGOUT_SUCCESS:
return new Set();
default:
return state;
}
}
function roles(state = {}, action) {
switch (action.type) {
case action_types_1.RoleTypes.RECEIVED_ROLES: {
if (action.data) {
const nextState = { ...state };
for (const role of action.data) {
nextState[role.name] = role;
}
return nextState;
}
return state;
}
case action_types_1.RoleTypes.RECEIVED_ROLE: {
if (action.data) {
const nextState = { ...state };
nextState[action.data.name] = action.data;
return nextState;
}
return state;
}
case action_types_1.UserTypes.LOGOUT_SUCCESS:
return {};
default:
return state;
}
}
exports.default = (0, redux_1.combineReducers)({
// object where the key is the category-name and has the corresponding value
roles,
pending,
});