diff --git a/packages/react-query/src/PoolSize.tsx b/packages/react-query/src/PoolSize.tsx index eeda75a..67f26f4 100644 --- a/packages/react-query/src/PoolSize.tsx +++ b/packages/react-query/src/PoolSize.tsx @@ -1,6 +1,7 @@ // Copyright 2017-2026 @pezkuwi/react-query authors & contributors // SPDX-License-Identifier: Apache-2.0 +import type { Option } from '@pezkuwi/types'; import type { PezpalletBrokerStatusRecord } from '@pezkuwi/types/lookup'; import React from 'react'; @@ -14,18 +15,11 @@ interface Props { function PoolSize ({ children, className = '' }: Props): React.ReactElement { const { api } = useApi(); - const status = useCall(api.query.broker?.status); - let systemPool = 0; - let privatePool = 0; - let poolSize = ''; - - if (status === undefined) { - poolSize = '0'; - } else { - systemPool = status.toJSON().systemPoolSize as number; - privatePool = status.toJSON().systemPoolSize as number; - poolSize = (systemPool + privatePool).toString(); - } + const status = useCall>(api.query.broker?.status); + const record = status?.unwrapOr(null); + const poolSize = record + ? record.systemPoolSize.add(record.privatePoolSize).toString() + : '0'; return (