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