Revert "fix: make error handling consistent for useTranches"

This reverts commit 357cbc45f8.
This commit is contained in:
Dexter 2022-05-25 09:41:04 +01:00
parent 357cbc45f8
commit 14f84608dd
4 changed files with 10 additions and 49 deletions

View File

@ -10,15 +10,15 @@ import type { RouteChildProps } from '..';
import Claim from './claim'; import Claim from './claim';
import { ClaimRestricted } from './claim-restricted'; import { ClaimRestricted } from './claim-restricted';
import { isRestricted } from './lib/is-restricted'; import { isRestricted } from './lib/is-restricted';
import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit'; import { Splash } from '@vegaprotocol/ui-toolkit';
const ClaimIndex = ({ name }: RouteChildProps) => { const ClaimIndex = ({ name }: RouteChildProps) => {
useDocumentTitle(name); useDocumentTitle(name);
const { t } = useTranslation(); const { t } = useTranslation();
const { account } = useWeb3React(); const { account } = useWeb3React();
const { tranches, loading, error } = useTranches(); const { tranches } = useTranches();
if (loading || !tranches) { if (!tranches) {
return ( return (
<Splash> <Splash>
<SplashLoader /> <SplashLoader />
@ -26,14 +26,6 @@ const ClaimIndex = ({ name }: RouteChildProps) => {
); );
} }
if (error) {
return (
<Callout intent={Intent.Danger} title={t('errorLoadingTranches')}>
{error}
</Callout>
);
}
let content = null; let content = null;
if (!account) { if (!account) {

View File

@ -1,18 +1,12 @@
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { import { EtherscanLink } from '@vegaprotocol/ui-toolkit';
Callout,
EtherscanLink,
Intent,
Splash,
} from '@vegaprotocol/ui-toolkit';
import { KeyValueTable, KeyValueTableRow } from '@vegaprotocol/ui-toolkit'; import { KeyValueTable, KeyValueTableRow } from '@vegaprotocol/ui-toolkit';
import { ADDRESSES } from '../../../config'; import { ADDRESSES } from '../../../config';
import { useTranches } from '../../../hooks/use-tranches'; import { useTranches } from '../../../hooks/use-tranches';
import type { BigNumber } from '../../../lib/bignumber'; import type { BigNumber } from '../../../lib/bignumber';
import { formatNumber } from '../../../lib/format-number'; import { formatNumber } from '../../../lib/format-number';
import { TokenDetailsCirculating } from './token-details-circulating'; import { TokenDetailsCirculating } from './token-details-circulating';
import { SplashLoader } from '../../../components/splash-loader';
export const TokenDetails = ({ export const TokenDetails = ({
totalSupply, totalSupply,
@ -23,24 +17,7 @@ export const TokenDetails = ({
}) => { }) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { tranches, loading, error } = useTranches(); const { tranches } = useTranches();
if (error) {
return (
<Callout intent={Intent.Danger} title={t('errorLoadingTranches')}>
{error}
</Callout>
);
}
if (!tranches || loading) {
return (
<Splash>
<SplashLoader />
</Splash>
);
}
return ( return (
<KeyValueTable className={'token-details'}> <KeyValueTable className={'token-details'}>
<KeyValueTableRow> <KeyValueTableRow>

View File

@ -28,7 +28,7 @@ const RedemptionRouter = () => {
appState: { trancheBalances }, appState: { trancheBalances },
} = useAppState(); } = useAppState();
const { account } = useWeb3React(); const { account } = useWeb3React();
const { tranches, error, loading } = useTranches(); const { tranches, error } = useTranches();
React.useEffect(() => { React.useEffect(() => {
const run = (address: string) => { const run = (address: string) => {
@ -59,7 +59,7 @@ const RedemptionRouter = () => {
); );
} }
if (!tranches || loading) { if (!tranches) {
return ( return (
<Splash> <Splash>
<SplashLoader /> <SplashLoader />

View File

@ -6,14 +6,14 @@ import { SplashLoader } from '../../components/splash-loader';
import { useDocumentTitle } from '../../hooks/use-document-title'; import { useDocumentTitle } from '../../hooks/use-document-title';
import { useTranches } from '../../hooks/use-tranches'; import { useTranches } from '../../hooks/use-tranches';
import type { RouteChildProps } from '..'; import type { RouteChildProps } from '..';
import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit'; import { Splash } from '@vegaprotocol/ui-toolkit';
const TrancheRouter = ({ name }: RouteChildProps) => { const TrancheRouter = ({ name }: RouteChildProps) => {
useDocumentTitle(name); useDocumentTitle(name);
const { t } = useTranslation(); const { t } = useTranslation();
const { tranches, error, loading } = useTranches(); const { tranches } = useTranches();
if (!tranches || loading) { if (!tranches) {
return ( return (
<Splash> <Splash>
<SplashLoader /> <SplashLoader />
@ -21,14 +21,6 @@ const TrancheRouter = ({ name }: RouteChildProps) => {
); );
} }
if (error) {
return (
<Callout intent={Intent.Danger} title={t('errorLoadingTranches')}>
{error}
</Callout>
);
}
return ( return (
<> <>
<Heading title={t('pageTitleTranches')} /> <Heading title={t('pageTitleTranches')} />