Memoize bunkerSigner

This commit is contained in:
Alex Gleason 2024-10-31 12:54:02 -05:00
parent efd5a54360
commit 45850fdb51
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 8 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { useMemo } from 'react';
import { keyring } from 'soapbox/features/nostr/keyring'; import { keyring } from 'soapbox/features/nostr/keyring';
import { useAppSelector } from 'soapbox/hooks'; import { useAppSelector } from 'soapbox/hooks';
@ -33,9 +34,15 @@ export function useSigner() {
enabled: !!pubkey, enabled: !!pubkey,
}); });
const bunkerSigner = useMemo(() => {
if (bunkerPubkey) {
return keyring.get(bunkerPubkey);
}
}, [bunkerPubkey]);
return { return {
signer: signer ?? undefined, signer: signer ?? undefined,
bunkerSigner: bunkerPubkey ? keyring.get(bunkerPubkey) : undefined, bunkerSigner,
authorizedPubkey, authorizedPubkey,
...rest, ...rest,
}; };