mattermost-redux
Version:
Common code (API client, Redux stores, logic, utility functions) for building a Mattermost client
32 lines (31 loc) • 1.08 kB
JavaScript
;
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
Object.defineProperty(exports, "__esModule", { value: true });
const action_types_1 = require("mattermost-redux/action_types");
exports.default = ((state = [], action) => {
switch (action.type) {
case action_types_1.ErrorTypes.DISMISS_ERROR: {
const nextState = [...state];
nextState.splice(action.index, 1);
return nextState;
}
case action_types_1.ErrorTypes.LOG_ERROR: {
const nextState = [...state];
const { displayable, error } = action;
nextState.push({
displayable,
error,
date: new Date(Date.now()).toUTCString(),
});
return nextState;
}
case action_types_1.ErrorTypes.RESTORE_ERRORS:
return action.data;
case action_types_1.ErrorTypes.CLEAR_ERRORS: {
return [];
}
default:
return state;
}
});