Page MenuHomePhabricator

D11389.id38360.diff
No OneTemporary

D11389.id38360.diff

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<?NeynarClientContextType> =
+ React.createContext<?NeynarClientContextType>();
+
+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 (
+ <NeynarClientContext.Provider value={context}>
+ {children}
+ </NeynarClientContext.Provider>
+ );
+}
+
+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 @@
>
<ActionSheetProvider>
<ENSCacheProvider provider={provider}>
- <MediaCacheProvider
- persistence={filesystemMediaCache}
- >
- <EditUserAvatarProvider>
- <NativeEditThreadAvatarProvider>
- <MarkdownContextProvider>
- <MessageSearchProvider>
- <BottomSheetProvider>
- <RegistrationContextProvider>
- <SQLiteDataHandler />
- <ConnectedStatusBar />
- <ReduxPersistGate
- persistor={getPersistor()}
- >
- {gated}
- </ReduxPersistGate>
- <PersistedStateGate>
- <KeyserverConnectionsHandler
- socketComponent={Socket}
- detectUnsupervisedBackgroundRef={
- detectUnsupervisedBackgroundRef
- }
- />
- <VersionSupportedChecker />
- <PrekeysHandler />
- <ReportHandler />
- <FarcasterDataHandler />
- </PersistedStateGate>
- {navigation}
- </RegistrationContextProvider>
- </BottomSheetProvider>
- </MessageSearchProvider>
- </MarkdownContextProvider>
- </NativeEditThreadAvatarProvider>
- </EditUserAvatarProvider>
- </MediaCacheProvider>
+ <NeynarClientProvider apiKey={neynarKey}>
+ <MediaCacheProvider
+ persistence={filesystemMediaCache}
+ >
+ <EditUserAvatarProvider>
+ <NativeEditThreadAvatarProvider>
+ <MarkdownContextProvider>
+ <MessageSearchProvider>
+ <BottomSheetProvider>
+ <RegistrationContextProvider>
+ <SQLiteDataHandler />
+ <ConnectedStatusBar />
+ <ReduxPersistGate
+ persistor={getPersistor()}
+ >
+ {gated}
+ </ReduxPersistGate>
+ <PersistedStateGate>
+ <KeyserverConnectionsHandler
+ socketComponent={Socket}
+ detectUnsupervisedBackgroundRef={
+ detectUnsupervisedBackgroundRef
+ }
+ />
+ <VersionSupportedChecker />
+ <PrekeysHandler />
+ <ReportHandler />
+ <FarcasterDataHandler />
+ </PersistedStateGate>
+ {navigation}
+ </RegistrationContextProvider>
+ </BottomSheetProvider>
+ </MessageSearchProvider>
+ </MarkdownContextProvider>
+ </NativeEditThreadAvatarProvider>
+ </EditUserAvatarProvider>
+ </MediaCacheProvider>
+ </NeynarClientProvider>
</ENSCacheProvider>
</ActionSheetProvider>
</SafeAreaProvider>

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 10, 4:34 AM (9 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2845123
Default Alt Text
D11389.id38360.diff (7 KB)

Event Timeline