From dfc22f3b4c0dbc9aa3e6d34421ee608553516253 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 2 Dec 2019 18:03:29 +0100 Subject: [PATCH] Add motion count --- packages/app-council/src/Motions/index.tsx | 14 ++++---------- packages/app-council/src/index.tsx | 10 ++++++++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/app-council/src/Motions/index.tsx b/packages/app-council/src/Motions/index.tsx index bcf9a5255d..5a430bd6f0 100644 --- a/packages/app-council/src/Motions/index.tsx +++ b/packages/app-council/src/Motions/index.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/camelcase */ // Copyright 2017-2019 @polkadot/app-democracy authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. @@ -7,7 +6,6 @@ import { Hash } from '@polkadot/types/interfaces'; import { I18nProps } from '@polkadot/react-components/types'; import React from 'react'; -import { withCalls } from '@polkadot/react-api'; import { CardGrid } from '@polkadot/react-components'; import Motion from './Motion'; @@ -15,10 +13,10 @@ import Propose from './Propose'; import translate from '../translate'; interface Props extends I18nProps { - council_proposals?: Hash[]; + motions?: Hash[]; } -function Proposals ({ council_proposals, t }: Props): React.ReactElement { +function Proposals ({ motions, t }: Props): React.ReactElement { return ( } > - {council_proposals && council_proposals.map((hash: Hash): React.ReactNode => ( + {motions?.map((hash: Hash): React.ReactNode => ( ); } -export default translate( - withCalls( - 'query.council.proposals' - )(Proposals) -); +export default translate(Proposals); diff --git a/packages/app-council/src/index.tsx b/packages/app-council/src/index.tsx index 1ffe9ad66e..0fbf28a756 100644 --- a/packages/app-council/src/index.tsx +++ b/packages/app-council/src/index.tsx @@ -2,6 +2,7 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +import { Hash } from '@polkadot/types/interfaces'; import { AppProps, BareProps, I18nProps } from '@polkadot/react-components/types'; import React from 'react'; @@ -9,6 +10,7 @@ import { Route, Switch } from 'react-router'; import { useLocation } from 'react-router-dom'; import styled from 'styled-components'; import { Tabs } from '@polkadot/react-components'; +import { useApi, trackStream } from '@polkadot/react-hooks'; import Overview from './Overview'; import Motions from './Motions'; @@ -17,7 +19,9 @@ import translate from './translate'; interface Props extends AppProps, BareProps, I18nProps {} function App ({ basePath, className, t }: Props): React.ReactElement { + const { api } = useApi(); const { pathname } = useLocation(); + const motions = trackStream(api.query.council.proposals, []); return (
@@ -36,13 +40,15 @@ function App ({ basePath, className, t }: Props): React.ReactElement { }, { name: 'motions', - text: t('Motions') + text: t('Motions ({{count}})', { replace: { count: motions?.length || 0 } }) } ]} /> - + + +