diff --git a/src/js/actions/WalletActions.js b/src/js/actions/WalletActions.js index 589e1dad..b7aaf6d6 100644 --- a/src/js/actions/WalletActions.js +++ b/src/js/actions/WalletActions.js @@ -3,7 +3,7 @@ import * as WALLET from './constants/wallet'; -import type { RouterLocationState } from '../flowtype'; +import type { RouterLocationState, ThunkAction, Dispatch, GetState } from '../flowtype'; export type WalletAction = { type: typeof WALLET.SET_INITIAL_URL, @@ -14,6 +14,23 @@ export type WalletAction = { 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 => { diff --git a/src/js/actions/constants/wallet.js b/src/js/actions/constants/wallet.js index 0b0299fb..ef68a1d4 100644 --- a/src/js/actions/constants/wallet.js +++ b/src/js/actions/constants/wallet.js @@ -3,4 +3,5 @@ export const ON_BEFORE_UNLOAD: 'wallet__on_before_unload' = 'wallet__on_before_unload'; export const TOGGLE_DEVICE_DROPDOWN: 'wallet__toggle_dropdown' = 'wallet__toggle_dropdown'; -export const SET_INITIAL_URL: 'wallet__set_initial_url' = 'wallet__set_initial_url'; \ No newline at end of file +export const SET_INITIAL_URL: 'wallet__set_initial_url' = 'wallet__set_initial_url'; +export const ONLINE_STATUS: 'wallet__online_status' = 'wallet__online_status'; \ No newline at end of file diff --git a/src/js/components/wallet/index.js b/src/js/components/wallet/index.js index 58d25deb..33b0e8ef 100644 --- a/src/js/components/wallet/index.js +++ b/src/js/components/wallet/index.js @@ -15,13 +15,20 @@ import ModalContainer from '../modal'; import Notifications from '../common/Notification'; import Log from '../common/Log'; +import type { MapStateToProps, MapDispatchToProps } from 'react-redux'; import type { State, Dispatch } from '../../flowtype'; -type Props = { - children: React.Node +type WalletContainerProps = { + wallet: $ElementType, + children?: React.Node } -const Content = (props: Props) => { +type ContentProps = { + children?: React.Node +} + + +const Content = (props: ContentProps) => { return (