From 42451e14a86f69d809e8fb75ee9097e3dc2b8ab7 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Thu, 24 Mar 2022 14:33:20 +0800 Subject: [PATCH] Split toast wrappers into separate file --- ui/redux/actions/comments.js | 3 ++- ui/util/api-message.js | 25 ------------------------- ui/util/toast-wrappers.js | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 26 deletions(-) create mode 100644 ui/util/toast-wrappers.js diff --git a/ui/redux/actions/comments.js b/ui/redux/actions/comments.js index 17e6f1ad8..164041d6d 100644 --- a/ui/redux/actions/comments.js +++ b/ui/redux/actions/comments.js @@ -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'; diff --git a/ui/util/api-message.js b/ui/util/api-message.js index 9b6ad9544..e2fae3fdb 100644 --- a/ui/util/api-message.js +++ b/ui/util/api-message.js @@ -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, diff --git a/ui/util/toast-wrappers.js b/ui/util/toast-wrappers.js new file mode 100644 index 000000000..c258eb066 --- /dev/null +++ b/ui/util/toast-wrappers.js @@ -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 +}