mirror of https://github.com/trezor/trezor-wallet
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.2 KiB
61 lines
1.2 KiB
/* @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>,
|
|
copied: boolean,
|
|
};
|
|
|
|
export const initialState: State = {
|
|
opened: false,
|
|
entries: [],
|
|
copied: false,
|
|
};
|
|
|
|
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,
|
|
copied: false,
|
|
};
|
|
|
|
case LOG.ADD:
|
|
return {
|
|
...state,
|
|
entries: state.entries.concat([action.payload]),
|
|
};
|
|
|
|
case LOG.COPY_SUCCESS:
|
|
return {
|
|
...state,
|
|
copied: true,
|
|
};
|
|
|
|
case LOG.COPY_RESET:
|
|
return {
|
|
...state,
|
|
copied: false,
|
|
};
|
|
|
|
default:
|
|
return state;
|
|
}
|
|
};
|