lbry-desktop/ui/util/toast-wrappers.js
infinite-persistence 2698cc7001
Add 'dispatchToast' wrapper
Just to shorten code, and easier to know what the parameters are if it's a function call (instead of an object).
2022-05-06 13:41:47 +08:00

23 lines
742 B
JavaScript

// @flow
import { doToast } from 'redux/actions/notifications';
export function dispatchToast(
dispatch: Dispatch,
message: string,
subMessage: string = '',
duration: 'default' | 'long' = 'default',
isError: boolean = true
) {
return dispatch(doToast({ message, subMessage: subMessage || undefined, duration: duration, isError }));
}
export function doFailedSignatureToast(dispatch: Dispatch, channelName: string) {
return dispatchToast(dispatch, __('Unable to verify signature.'), channelName);
}
export function devToast(dispatch: Dispatch, msg: string) {
// @if process.env.NODE_ENV!='production'
console.error(msg); // eslint-disable-line
dispatch(doToast({ isError: true, message: `DEV: ${msg}` }));
// @endif
}