From 6ae747b9e317b437eb2117263472a2b8757bf1f8 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Sun, 29 Nov 2020 22:50:12 +0100 Subject: [PATCH] Display activeEraStart with Babe (#4105) --- packages/page-explorer/src/SummarySession.tsx | 11 +++++++++++ packages/react-query/src/Elapsed.tsx | 7 ++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/page-explorer/src/SummarySession.tsx b/packages/page-explorer/src/SummarySession.tsx index b83d555001..d147c0349d 100644 --- a/packages/page-explorer/src/SummarySession.tsx +++ b/packages/page-explorer/src/SummarySession.tsx @@ -7,6 +7,7 @@ import type { Forcing } from '@polkadot/types/interfaces'; import React from 'react'; import { CardSummary } from '@polkadot/react-components'; import { useApi, useCall } from '@polkadot/react-hooks'; +import { Elapsed } from '@polkadot/react-query'; import { formatNumber } from '@polkadot/util'; import { useTranslation } from './translate'; @@ -26,6 +27,7 @@ function SummarySession ({ withEra = true, withSession = true }: Props): React.R const sessionLabel = sessionInfo?.isEpoch ? t('epoch') : t('session'); + const activeEraStart = sessionInfo?.activeEraStart.unwrapOr(null); return ( <> @@ -46,6 +48,7 @@ function SummarySession ({ withEra = true, withSession = true }: Props): React.R : ( #{formatNumber(sessionInfo.currentIndex)} + {withEra && activeEraStart &&
 
}
) )} @@ -64,6 +67,14 @@ function SummarySession ({ withEra = true, withSession = true }: Props): React.R : ( #{formatNumber(sessionInfo.activeEra)} + {activeEraStart && ( + +  {t('elpased')} + + )} ) )} diff --git a/packages/react-query/src/Elapsed.tsx b/packages/react-query/src/Elapsed.tsx index 4ac3a9b034..56b73ba4e5 100644 --- a/packages/react-query/src/Elapsed.tsx +++ b/packages/react-query/src/Elapsed.tsx @@ -8,6 +8,7 @@ import { bnToBn } from '@polkadot/util'; type Ticker = (now: number) => void; interface Props { + children?: React.ReactNode; className?: string; value?: BN | Date | number; } @@ -55,7 +56,7 @@ function getDisplayValue (now = 0, value: BN | Date | number = 0): string { tick(); -function Elapsed ({ className = '', value }: Props): React.ReactElement { +function Elapsed ({ children, className = '', value }: Props): React.ReactElement { const [now, setNow] = useState(lastNow); useEffect((): () => void => { @@ -69,8 +70,8 @@ function Elapsed ({ className = '', value }: Props): React.ReactElement { }, []); return ( -
- {getDisplayValue(now, value)} +
+ {getDisplayValue(now, value)}{children}
); }