diff --git a/lib/components/neynar-client-provider.react.js b/lib/components/neynar-client-provider.react.js new file mode 100644 --- /dev/null +++ b/lib/components/neynar-client-provider.react.js @@ -0,0 +1,44 @@ +// @flow + +import * as React from 'react'; + +import { NeynarClient } from '../utils/neynar-client.js'; + +type NeynarClientContextType = { + +client: NeynarClient, +}; + +const NeynarClientContext: React.Context = + React.createContext(); + +type Props = { + +apiKey: ?string, + +children: React.Node, +}; +function NeynarClientProvider(props: Props): React.Node { + const { apiKey, children } = props; + + const neynarClient = React.useMemo(() => { + if (!apiKey) { + return null; + } + return new NeynarClient(apiKey); + }, [apiKey]); + + const context = React.useMemo(() => { + if (!neynarClient) { + return null; + } + return { + client: neynarClient, + }; + }, [neynarClient]); + + return ( + + {children} + + ); +} + +export { NeynarClientContext, NeynarClientProvider }; diff --git a/native/root.react.js b/native/root.react.js --- a/native/root.react.js +++ b/native/root.react.js @@ -30,6 +30,7 @@ import IntegrityHandler from 'lib/components/integrity-handler.react.js'; import KeyserverConnectionsHandler from 'lib/components/keyserver-connections-handler.js'; import { MediaCacheProvider } from 'lib/components/media-cache-provider.react.js'; +import { NeynarClientProvider } from 'lib/components/neynar-client-provider.react.js'; import PrekeysHandler from 'lib/components/prekeys-handler.react.js'; import { StaffContextProvider } from 'lib/components/staff-provider.react.js'; import { IdentitySearchProvider } from 'lib/identity-search/identity-search-context.js'; @@ -82,6 +83,7 @@ import { DarkTheme, LightTheme } from './themes/navigation.js'; import ThemeHandler from './themes/theme-handler.react.js'; import { provider } from './utils/ethers-utils.js'; +import { neynarKey } from './utils/neynar-utils.js'; import { useTunnelbrokerInitMessage } from './utils/tunnelbroker-utils.js'; // Add custom items to expo-dev-menu @@ -318,42 +320,44 @@ > - - - - - - - - - - - {gated} - - - - - - - - - {navigation} - - - - - - - + + + + + + + + + + + + {gated} + + + + + + + + + {navigation} + + + + + + + +