MyCrypto/common/actions/notifications/actionCreators.ts
William O'Beirne 1221a73a46 Better Offline Detection / Handling (#478)
* Change navigator.onLine to actually pinging the network. Refactor notifications to take Infinity instead of 'infinity'

* Stop polling when forced offline.

* Show spinners if unit display balance is null, show offline text if were actually offline.

* Fix issue with typescript and connected union-prop components.

* Only ping the node when navigator.onLine changes.
2017-11-28 18:17:26 -06:00

31 lines
732 B
TypeScript

import { ReactElement } from 'react';
import * as types from './actionTypes';
import { TypeKeys } from './constants';
export type TShowNotification = typeof showNotification;
export function showNotification(
level: types.NOTIFICATION_LEVEL = 'info',
msg: ReactElement<any> | string,
duration?: number
): types.ShowNotificationAction {
return {
type: TypeKeys.SHOW_NOTIFICATION,
payload: {
level,
msg,
duration,
id: Math.random()
}
};
}
export type TCloseNotification = typeof closeNotification;
export function closeNotification(
notification: types.Notification
): types.CloseNotificationAction {
return {
type: TypeKeys.CLOSE_NOTIFICATION,
payload: notification
};
}