2017-01-09 23:09:23 +00:00
|
|
|
import * as ActionTypes from '../../../constants';
|
|
|
|
|
2018-10-25 22:03:45 +00:00
|
|
|
const consoleMax = 500;
|
2017-01-09 23:09:23 +00:00
|
|
|
const initialState = [];
|
|
|
|
|
|
|
|
const console = (state = initialState, action) => {
|
2017-02-22 19:29:35 +00:00
|
|
|
let messages;
|
2017-01-09 23:09:23 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case ActionTypes.CONSOLE_EVENT:
|
2017-02-22 19:29:35 +00:00
|
|
|
messages = [...action.event];
|
|
|
|
return state.concat(messages).slice(-consoleMax);
|
2017-01-09 23:09:23 +00:00
|
|
|
case ActionTypes.CLEAR_CONSOLE:
|
|
|
|
return [];
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default console;
|