ghost-portal/packages/page-tech-comm/src/useCounter.ts
Jaco 42cb6b84d3
Rework collective queries (#5732)
* Rework collective queries

* members derive

* All via derive

* Adjust society useMembers

* Adjust optional consts

* Detect council module locations

* Adjust tech comm with module locations

* Rework loading

* Unused type import
2021-07-02 10:42:13 +02:00

18 lines
543 B
TypeScript

// Copyright 2017-2021 @polkadot/app-tech-comm authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Hash } from '@polkadot/types/interfaces';
import { useApi, useCall } from '@polkadot/react-hooks';
const transformCounter = {
transform: (proposals: Hash[]) => proposals.length
};
export default function useCounter (): number {
const { api, isApiReady } = useApi();
const counter = useCall<number>(isApiReady && api.derive.technicalCommittee?.proposals, undefined, transformCounter) || 0;
return counter;
}