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.
trezor-wallet/src/js/actions/LogActions.js

46 lines
983 B

6 years ago
/* @flow */
'use strict';
import * as LOG from './constants/log';
6 years ago
import type { Action, ThunkAction, GetState, Dispatch } from '../flowtype';
import type { LogEntry } from '../reducers/LogReducer';
export type LogAction = {
type: typeof LOG.OPEN,
} | {
type: typeof LOG.CLOSE,
6 years ago
} | {
type: typeof LOG.ADD,
payload: LogEntry
};
6 years ago
export const toggle = (): ThunkAction => {
return (dispatch: Dispatch, getState: GetState): void => {
6 years ago
if (!getState().log.opened) {
window.scrollTo(0, 0);
6 years ago
dispatch({
6 years ago
type: LOG.OPEN
6 years ago
});
} else {
dispatch({
6 years ago
type: LOG.CLOSE
6 years ago
});
}
6 years ago
}
}
6 years ago
// export const add = (type: string, message: string): Action => {
export const add = (type: string, message: any): Action => {
return {
type: LOG.ADD,
payload: {
time: new Date().getTime(),
type,
message
}
}
}