2018-03-08 16:10:53 +00:00
|
|
|
/* @flow */
|
|
|
|
'use strict';
|
|
|
|
|
2018-04-16 21:19:50 +00:00
|
|
|
import * as LOG from '../actions/constants/log';
|
2018-05-18 16:54:21 +00:00
|
|
|
import type { Action } from '~/flowtype';
|
2018-04-16 21:19:50 +00:00
|
|
|
|
2018-05-05 11:52:03 +00:00
|
|
|
export type LogEntry = {
|
2018-03-08 16:10:53 +00:00
|
|
|
time: number;
|
|
|
|
type: string;
|
2018-05-05 11:52:03 +00:00
|
|
|
// message: string;
|
|
|
|
message: any;
|
2018-03-08 16:10:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export type State = {
|
|
|
|
opened: boolean;
|
|
|
|
entries: Array<LogEntry>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const initialState: State = {
|
|
|
|
opened: false,
|
|
|
|
entries: [],
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-04-16 21:19:50 +00:00
|
|
|
export default (state: State = initialState, action: Action): State => {
|
2018-03-08 16:10:53 +00:00
|
|
|
|
|
|
|
switch (action.type) {
|
|
|
|
|
2018-05-05 11:52:03 +00:00
|
|
|
case LOG.OPEN :
|
2018-03-08 16:10:53 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
opened: true
|
|
|
|
}
|
|
|
|
|
2018-05-05 11:52:03 +00:00
|
|
|
case LOG.CLOSE :
|
2018-03-08 16:10:53 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
opened: false
|
|
|
|
}
|
|
|
|
|
2018-05-05 11:52:03 +00:00
|
|
|
case LOG.ADD :
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
entries: state.entries.concat([ action.payload ])
|
|
|
|
}
|
2018-03-08 16:10:53 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|