1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-12-03 13:48:15 +00:00
trezor-wallet/src/reducers/LogReducer.js
Szymon Lesisz d78381106e Filter log
2018-10-09 15:36:55 +02:00

46 lines
871 B
JavaScript

/* @flow */
import * as LOG from 'actions/constants/log';
import type { Action } from 'flowtype';
export type LogEntry = {
time: number;
type: string;
message: any;
}
export type State = {
opened: boolean;
entries: Array<LogEntry>;
}
export const initialState: State = {
opened: false,
entries: [],
};
export default (state: State = initialState, action: Action): State => {
switch (action.type) {
case LOG.OPEN:
return {
...state,
opened: true,
};
case LOG.CLOSE:
return {
...state,
opened: false,
};
case LOG.ADD:
return {
...state,
entries: state.entries.concat([action.payload]),
};
default:
return state;
}
};