mattermost-redux
Version:
Common code (API client, Redux stores, logic, utility functions) for building a Mattermost client
38 lines (37 loc) • 1.3 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 schemes(state = {}, action) {
switch (action.type) {
case action_types_1.SchemeTypes.CREATED_SCHEME:
case action_types_1.SchemeTypes.PATCHED_SCHEME:
case action_types_1.SchemeTypes.RECEIVED_SCHEME: {
return {
...state,
[action.data.id]: action.data,
};
}
case action_types_1.SchemeTypes.RECEIVED_SCHEMES: {
const nextState = { ...state };
for (const scheme of action.data) {
nextState[scheme.id] = scheme;
}
return nextState;
}
case action_types_1.SchemeTypes.DELETED_SCHEME: {
const nextState = { ...state };
Reflect.deleteProperty(nextState, action.data.schemeId);
return nextState;
}
case action_types_1.UserTypes.LOGOUT_SUCCESS:
return {};
default:
return state;
}
}
exports.default = (0, redux_1.combineReducers)({
schemes,
});