1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-13 20:08:56 +00:00
trezor-wallet/src/js/reducers/LogReducer.js

48 lines
901 B
JavaScript
Raw Normal View History

2018-03-08 16:10:53 +00:00
/* @flow */
2018-07-30 10:52:13 +00:00
2018-03-08 16:10:53 +00:00
2018-04-16 21:19:50 +00:00
import * as LOG from '../actions/constants/log';
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-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
};