1 import { useCallback } from 'react';
3 import { CacheType, createHooks } from '@proton/redux-utilities';
5 import { bitcoinAddressHighestIndexThunk, selectBitcoinAddressHighestIndex } from '../slices';
7 const hooks = createHooks(bitcoinAddressHighestIndexThunk, selectBitcoinAddressHighestIndex);
9 // FIXME: We don't expose useValue hook on purpose because it doesn't support well maps
11 // export const useBitcoinAddressHighestIndex = (walletAccountId: string) => {
12 // const [value, loading] = hooks.useValue();
14 // return useMemo(() => {
15 // return [value?.[walletAccountId]?.index, loading];
16 // }, [loading, value, walletAccountId]);
19 export const useGetBitcoinAddressHighestIndex = () => {
20 const get = hooks.useGet();
22 async (walletId: string, walletAccountId: string) => {
23 const results = await get({ thunkArg: [walletId, walletAccountId], cache: CacheType.None });
24 return results[walletAccountId]?.index ?? 0;