Merge branch 'memo-signer' into 'main'
NostrProvider: memoize the signer See merge request soapbox-pub/soapbox!2958
This commit is contained in:
commit
c24fc10c93
1 changed files with 5 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { NRelay, NRelay1, NostrSigner } from '@soapbox/nspec';
|
import { NRelay, NRelay1, NostrSigner } from '@soapbox/nspec';
|
||||||
import React, { createContext, useContext, useState, useEffect } from 'react';
|
import React, { createContext, useContext, useState, useEffect, useMemo } from 'react';
|
||||||
|
|
||||||
import { NKeys } from 'soapbox/features/nostr/keys';
|
import { NKeys } from 'soapbox/features/nostr/keys';
|
||||||
import { useOwnAccount } from 'soapbox/hooks';
|
import { useOwnAccount } from 'soapbox/hooks';
|
||||||
|
@ -27,7 +27,10 @@ export const NostrProvider: React.FC<NostrProviderProps> = ({ children }) => {
|
||||||
const pubkey = instance.nostr?.pubkey;
|
const pubkey = instance.nostr?.pubkey;
|
||||||
const accountPubkey = account?.nostr.pubkey;
|
const accountPubkey = account?.nostr.pubkey;
|
||||||
|
|
||||||
const signer = (accountPubkey ? NKeys.get(accountPubkey) : undefined) ?? window.nostr;
|
const signer = useMemo(
|
||||||
|
() => (accountPubkey ? NKeys.get(accountPubkey) : undefined) ?? window.nostr,
|
||||||
|
[accountPubkey],
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (url) {
|
if (url) {
|
||||||
|
|
Loading…
Reference in a new issue