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

61 lines
1.2 KiB
JavaScript
Raw Normal View History

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 = {
2019-03-04 12:33:02 +00:00
time: number,
type: string,
message: any,
};
2018-03-08 16:10:53 +00:00
export type State = {
2019-03-04 13:03:53 +00:00
opened: boolean,
entries: Array<LogEntry>,
copied: boolean,
};
2018-03-08 16:10:53 +00:00
export const initialState: State = {
opened: false,
entries: [],
2019-03-04 11:52:26 +00:00
copied: false,
2018-03-08 16:10:53 +00:00
};
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,
2019-03-04 11:52:26 +00:00
copied: false,
2018-07-30 10:52:13 +00:00
};
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
2019-03-04 11:52:26 +00:00
case LOG.COPY_SUCCESS:
return {
...state,
copied: true,
};
2019-03-04 14:36:04 +00:00
case LOG.COPY_RESET:
return {
...state,
copied: false,
};
2018-03-08 16:10:53 +00:00
default:
return state;
}
2019-03-04 12:33:02 +00:00
};