Use derive call in Bounty's useCounter (#4290)
* Use derive call in Bounty's useCounter * Remove derive.treasury from useCall
This commit is contained in:
parent
22b54bdbb9
commit
6421bd360c
@ -1,18 +1,17 @@
|
||||
// Copyright 2017-2020 @polkadot/app-bounties authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { BountyIndex } from '@polkadot/types/interfaces';
|
||||
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { DeriveBounties } from '@polkadot/api-derive/types';
|
||||
import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
|
||||
export default function useCounter (): number {
|
||||
const { api, isApiReady } = useApi();
|
||||
const bounties = useCall<BountyIndex>(isApiReady && (api.query.bounties || api.query.treasury)?.bountyCount);
|
||||
const bounties = useCall<DeriveBounties>(isApiReady && api.derive.bounties?.bounties);
|
||||
|
||||
return useMemo(
|
||||
() => bounties?.toNumber() || 0,
|
||||
() => bounties?.length || 0,
|
||||
[bounties]
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user