Use source loader for email sprite icons
[ProtonMail-WebClient.git] / packages / wallet / store / hooks / useBitcoinAddressHighestIndex.ts
blob6870c7464be4306246917a5df4156a372c00cc63
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]);
17 // };
19 export const useGetBitcoinAddressHighestIndex = () => {
20     const get = hooks.useGet();
21     return useCallback(
22         async (walletId: string, walletAccountId: string) => {
23             const results = await get({ thunkArg: [walletId, walletAccountId], cache: CacheType.None });
24             return results[walletAccountId]?.index ?? 0;
25         },
26         [get]
27     );