Split toast wrappers into separate file

This commit is contained in:
infinite-persistence 2022-03-24 14:33:20 +08:00
parent e0ddd94c01
commit 42451e14a8
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
3 changed files with 20 additions and 26 deletions

View file

@ -4,8 +4,9 @@ import * as REACTION_TYPES from 'constants/reactions';
import * as PAGES from 'constants/pages';
import { SORT_BY, BLOCK_LEVEL } from 'constants/comment';
import Lbry from 'lbry';
import { resolveApiMessage } from 'util/api-message';
import { parseURI, buildURI, isURIEqual } from 'util/lbryURI';
import { devToast, doFailedSignatureToast, resolveApiMessage } from 'util/api-message';
import { devToast, doFailedSignatureToast } from 'util/toast-wrappers';
import { selectClaimForUri, selectClaimsByUri, selectMyChannelClaims } from 'redux/selectors/claims';
import { doResolveUris, doClaimSearch } from 'redux/actions/claims';
import { doToast, doSeeNotifications } from 'redux/actions/notifications';

View file

@ -1,29 +1,4 @@
// @flow
import { doToast } from 'redux/actions/notifications';
// ****************************************************************************
// Helpers
// ****************************************************************************
export function doFailedSignatureToast(dispatch: Dispatch, channelName: string) {
dispatch(
doToast({
message: __('Unable to verify signature for %channel%.', { channel: channelName }),
isError: true,
})
);
}
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
}
// ****************************************************************************
// Error mapping
// ****************************************************************************
type ApiMsgConfig = {
originalMsg: string | RegExp,

18
ui/util/toast-wrappers.js Normal file
View file

@ -0,0 +1,18 @@
// @flow
import { doToast } from 'redux/actions/notifications';
export function doFailedSignatureToast(dispatch: Dispatch, channelName: string) {
dispatch(
doToast({
message: __('Unable to verify signature for %channel%.', { channel: channelName }),
isError: true,
})
);
}
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
}