Render staking accounts in background (#1967)
* Render staking accounts in background * Extract location.pathname
This commit is contained in:
parent
536a2ccc08
commit
488c9654f4
@ -9,7 +9,7 @@ import { ComponentProps } from './types';
|
||||
|
||||
import React from 'react';
|
||||
import { Route, Switch } from 'react-router';
|
||||
import { useRouteMatch } from 'react-router-dom';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import styled from 'styled-components';
|
||||
import { Option } from '@polkadot/types';
|
||||
import { HelpOverlay } from '@polkadot/react-components';
|
||||
@ -43,12 +43,12 @@ function transformStakingControllers ([stashes, controllers]: [AccountId[], Opti
|
||||
function App ({ basePath, className, t }: Props): React.ReactElement<Props> {
|
||||
const { api } = useApi();
|
||||
const { allAccounts, hasAccounts } = useAccounts();
|
||||
const { pathname } = useLocation();
|
||||
const stakingControllers = trackStream<[string[], string[]]>(api.derive.staking.controllers, [], { transform: transformStakingControllers });
|
||||
const bestNumber = trackStream<BlockNumber>(api.derive.chain.bestNumber, []);
|
||||
const recentlyOnline = trackStream<DerivedHeartbeats>(api.derive.imOnline.receivedHeartbeats, []);
|
||||
const stakingOverview = trackStream<DerivedStakingOverview>(api.derive.staking.overview, []);
|
||||
const sessionRewards = useSessionRewards(MAX_SESSIONS);
|
||||
const routeMatch = useRouteMatch({ path: basePath, strict: true });
|
||||
|
||||
const hasQueries = hasAccounts && !!(api.query.imOnline?.authoredBlocks);
|
||||
const [allStashes, allControllers] = stakingControllers || EMPTY_ALL;
|
||||
@ -103,12 +103,12 @@ function App ({ basePath, className, t }: Props): React.ReactElement<Props> {
|
||||
/>
|
||||
</header>
|
||||
<Switch>
|
||||
<Route path={`${basePath}/actions`}>{_renderComponent(Actions)}</Route>
|
||||
<Route path={`${basePath}/query/:value`}>{_renderComponent(Query)}</Route>
|
||||
<Route path={`${basePath}/query`}>{_renderComponent(Query)}</Route>
|
||||
<Route path={`${basePath}/returns`}>{_renderComponent(Targets)}</Route>
|
||||
</Switch>
|
||||
{_renderComponent(Overview, routeMatch?.isExact ? '' : 'staking--hidden')}
|
||||
{_renderComponent(Actions, pathname === `${basePath}/actions` ? '' : 'staking--hidden')}
|
||||
{_renderComponent(Overview, pathname === basePath ? '' : 'staking--hidden')}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user