mattermost-redux
Version:
Common code (API client, Redux stores, logic, utility functions) for building a Mattermost client
32 lines (31 loc) • 1.06 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 accounts(state = {}, action) {
switch (action.type) {
case action_types_1.BotTypes.RECEIVED_BOT_ACCOUNTS: {
const newBots = action.data;
const nextState = { ...state };
for (const bot of newBots) {
nextState[bot.user_id] = bot;
}
return nextState;
}
case action_types_1.BotTypes.RECEIVED_BOT_ACCOUNT: {
const bot = action.data;
const nextState = { ...state };
nextState[bot.user_id] = bot;
return nextState;
}
case action_types_1.UserTypes.LOGOUT_SUCCESS:
return {};
default:
return state;
}
}
exports.default = (0, redux_1.combineReducers)({
accounts,
});