From ba5b3c45a0d6492af804fd469ce94d7e491eb9a8 Mon Sep 17 00:00:00 2001 From: Jaco Date: Wed, 4 May 2022 14:15:05 +0200 Subject: [PATCH] Improve poll loading experience (#7522) --- packages/page-staking/src/Pools/Pool.tsx | 107 +++++++++++----------- packages/page-staking/src/Pools/Pools.tsx | 2 +- 2 files changed, 57 insertions(+), 52 deletions(-) diff --git a/packages/page-staking/src/Pools/Pool.tsx b/packages/page-staking/src/Pools/Pool.tsx index 2840ecbdf0..c44e42fd0e 100644 --- a/packages/page-staking/src/Pools/Pool.tsx +++ b/packages/page-staking/src/Pools/Pool.tsx @@ -7,7 +7,7 @@ import type { MembersMapEntry, Params } from './types'; import React, { useCallback } from 'react'; import styled from 'styled-components'; -import { AddressMini, ExpandButton, ExpanderScroll } from '@polkadot/react-components'; +import { AddressMini, ExpandButton, ExpanderScroll, Spinner } from '@polkadot/react-components'; import { useToggle } from '@polkadot/react-hooks'; import { FormatBalance } from '@polkadot/react-query'; import { formatNumber } from '@polkadot/util'; @@ -24,7 +24,7 @@ interface Props { poolId: BN; } -function Pool ({ className = '', members, ownAccounts, params, poolId }: Props): React.ReactElement | null { +function Pool ({ className = '', members, ownAccounts, params, poolId }: Props): React.ReactElement { const { t } = useTranslation(); const info = usePoolInfo(poolId); const [isExpanded, toggleExpanded] = useToggle(false); @@ -42,18 +42,14 @@ function Pool ({ className = '', members, ownAccounts, params, poolId }: Props): [members] ); - if (!info) { - return null; - } - return ( <>

{formatNumber(poolId)}

- {info.metadata} - {info.bonded.state.type} - - {!info.rewardClaimable.isZero() && } + {info && info.metadata} + {info && info.bonded.state.type} + {info && } + {info && !info.rewardClaimable.isZero() && } {members && members.length !== 0 && ( - - - - - - -
-
{t('root')}
-
-
-
-
{t('creator')}
-
-
-
-
{t('nominator')}
-
-
-
-
{t('toggler')}
-
-
- - - -
-
{t('stash')}
-
-
-
-
{t('rewards')}
-
-
+ {info + ? ( + <> + + + + ) + : + } + {info && ( + + +
+
{t('root')}
+
+
+
+
{t('creator')}
+
+
+
+
{t('nominator')}
+
+
+
+
{t('toggler')}
+
+
+ + + +
+
{t('stash')}
+
+
+
+
{t('rewards')}
+
+
+ + + )} ); } diff --git a/packages/page-staking/src/Pools/Pools.tsx b/packages/page-staking/src/Pools/Pools.tsx index b6f9d1e020..253a0bb6bb 100644 --- a/packages/page-staking/src/Pools/Pools.tsx +++ b/packages/page-staking/src/Pools/Pools.tsx @@ -75,7 +75,7 @@ function Pools ({ className, ids, ownPools, params }: Props): React.ReactElement ('No available nomination pools')} + empty={membersMap && filtered && t('No available nomination pools')} emptySpinner={t('Retrieving nomination pools')} header={header} withCollapsibleRows