2018-03-08 16:10:53 +00:00
|
|
|
/* @flow */
|
2018-07-30 10:52:13 +00:00
|
|
|
|
2018-08-14 13:11:52 +00:00
|
|
|
import * as LOG from 'actions/constants/log';
|
2018-08-14 12:56:47 +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: 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-07-30 10:52:13 +00:00
|
|
|
case LOG.OPEN:
|
2018-03-08 16:10:53 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2018-07-30 10:52:13 +00:00
|
|
|
opened: true,
|
|
|
|
};
|
2018-03-08 16:10:53 +00:00
|
|
|
|
2018-07-30 10:52:13 +00:00
|
|
|
case LOG.CLOSE:
|
2018-03-08 16:10:53 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2018-07-30 10:52:13 +00:00
|
|
|
opened: false,
|
|
|
|
};
|
2018-03-08 16:10:53 +00:00
|
|
|
|
2018-07-30 10:52:13 +00:00
|
|
|
case LOG.ADD:
|
2018-05-05 11:52:03 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2018-07-30 10:52:13 +00:00
|
|
|
entries: state.entries.concat([action.payload]),
|
|
|
|
};
|
2018-03-08 16:10:53 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
2018-07-30 10:52:13 +00:00
|
|
|
};
|