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/WalletActions.js

48 lines
1.1 KiB

/* @flow */
'use strict';
import * as WALLET from './constants/wallet';
import type { RouterLocationState, ThunkAction, Dispatch, GetState } from '~/flowtype';
export type WalletAction = {
type: typeof WALLET.SET_INITIAL_URL,
state?: RouterLocationState,
pathname?: string
} | {
type: typeof WALLET.TOGGLE_DEVICE_DROPDOWN,
opened: boolean
} | {
type: typeof WALLET.ON_BEFORE_UNLOAD
} | {
type: typeof WALLET.ONLINE_STATUS,
online: boolean
}
export const init = (): ThunkAction => {
return (dispatch: Dispatch, getState: GetState): void => {
const updateOnlineStatus = (event) => {
dispatch({
type: WALLET.ONLINE_STATUS,
online: navigator.onLine
})
}
window.addEventListener('online', updateOnlineStatus);
window.addEventListener('offline', updateOnlineStatus);
}
}
export const onBeforeUnload = (): WalletAction => {
return {
type: WALLET.ON_BEFORE_UNLOAD
}
}
export const toggleDeviceDropdown = (opened: boolean): WalletAction => {
return {
type: WALLET.TOGGLE_DEVICE_DROPDOWN,
opened
}
}