Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3327067
D13975.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D13975.diff
View Options
diff --git a/keyserver/src/creators/farcaster-channel-tag-creator.js b/keyserver/src/creators/farcaster-channel-tag-creator.js
--- a/keyserver/src/creators/farcaster-channel-tag-creator.js
+++ b/keyserver/src/creators/farcaster-channel-tag-creator.js
@@ -32,7 +32,7 @@
import { Viewer } from '../session/viewer.js';
import { updateThread } from '../updaters/thread-updaters.js';
import { thisKeyserverID } from '../user/identity.js';
-import { neynarClient } from '../utils/fc-cache.js';
+import { fcCache } from '../utils/fc-cache.js';
import { getAndAssertKeyserverURLFacts } from '../utils/urls.js';
async function createOrUpdateFarcasterChannelTag(
@@ -137,10 +137,10 @@
}
const neynarChannelDescriptionPromise = (async () => {
- if (!neynarClient) {
+ if (!fcCache) {
return '';
}
- const channelInfo = await neynarClient?.fetchFarcasterChannelByID(
+ const channelInfo = await fcCache?.getFarcasterChannelForChannelID(
request.farcasterChannelID,
);
return channelInfo?.description ?? '';
diff --git a/keyserver/src/responders/farcaster-webhook-responders.js b/keyserver/src/responders/farcaster-webhook-responders.js
--- a/keyserver/src/responders/farcaster-webhook-responders.js
+++ b/keyserver/src/responders/farcaster-webhook-responders.js
@@ -35,7 +35,7 @@
import { thisKeyserverAdmin, thisKeyserverID } from '../user/identity.js';
import { getFarcasterBotConfig } from '../utils/farcaster-bot.js';
import { getVerifiedUserIDForFID } from '../utils/farcaster-utils.js';
-import { neynarClient } from '../utils/fc-cache.js';
+import { neynarClient, fcCache } from '../utils/fc-cache.js';
import { getNeynarConfig } from '../utils/neynar-utils.js';
const taggedCommFarcasterInputValidator =
@@ -131,7 +131,7 @@
const keyserverAdminPromise = thisKeyserverAdmin();
const neynarChannel =
- await neynarClient?.fetchFarcasterChannelByID(channelID);
+ await fcCache?.getFarcasterChannelForChannelID(channelID);
if (!neynarChannel) {
throw new ServerError('channel_not_found');
}
diff --git a/keyserver/src/updaters/thread-updaters.js b/keyserver/src/updaters/thread-updaters.js
--- a/keyserver/src/updaters/thread-updaters.js
+++ b/keyserver/src/updaters/thread-updaters.js
@@ -67,7 +67,7 @@
verifyUserOrCookieIDs,
} from '../fetchers/user-fetchers.js';
import type { Viewer } from '../session/viewer.js';
-import { neynarClient } from '../utils/fc-cache.js';
+import { neynarClient, fcCache } from '../utils/fc-cache.js';
import { findUserIdentities } from '../utils/identity-utils.js';
import { redisCache } from '../utils/redis-cache.js';
import RelationshipChangeset from '../utils/relationship-changeset.js';
@@ -1001,7 +1001,7 @@
})(),
);
- const channelInfo = await neynarClient?.fetchFarcasterChannelByID(
+ const channelInfo = await fcCache?.getFarcasterChannelForChannelID(
communityFarcasterChannelTag,
);
if (channelInfo) {
diff --git a/keyserver/src/utils/fc-cache.js b/keyserver/src/utils/fc-cache.js
--- a/keyserver/src/utils/fc-cache.js
+++ b/keyserver/src/utils/fc-cache.js
@@ -10,8 +10,9 @@
import { getNeynarConfig } from './neynar-utils.js';
-let getFCNames: ?GetFCNames;
let neynarClient: ?NeynarClient;
+let fcCache: ?FCCache;
+let getFCNames: ?GetFCNames;
async function initFCCache() {
const neynarSecret = await getNeynarConfig();
@@ -20,9 +21,10 @@
return;
}
neynarClient = new NeynarClient(neynarKey);
- const fcCache = new FCCache(neynarClient);
+ const newFCCache = new FCCache(neynarClient);
+ fcCache = newFCCache;
getFCNames = <T: ?BaseFCNamesInfo>(users: $ReadOnlyArray<T>): Promise<T[]> =>
- baseGetFCNames(fcCache, users);
+ baseGetFCNames(newFCCache, users);
}
-export { initFCCache, getFCNames, neynarClient };
+export { initFCCache, neynarClient, fcCache, getFCNames };
diff --git a/native/community-settings/tag-farcaster-channel/tag-farcaster-channel-by-name.react.js b/native/community-settings/tag-farcaster-channel/tag-farcaster-channel-by-name.react.js
--- a/native/community-settings/tag-farcaster-channel/tag-farcaster-channel-by-name.react.js
+++ b/native/community-settings/tag-farcaster-channel/tag-farcaster-channel-by-name.react.js
@@ -49,7 +49,7 @@
const onPressTagChannel = React.useCallback(async () => {
const channelInfo =
- await neynarClientContext.client.fetchFarcasterChannelByID(
+ await neynarClientContext.fcCache.getFarcasterChannelForChannelID(
channelSelectionText,
);
@@ -59,7 +59,7 @@
}
createTag(channelInfo.id);
- }, [channelSelectionText, createTag, neynarClientContext.client]);
+ }, [channelSelectionText, createTag, neynarClientContext.fcCache]);
const errorMessage = React.useMemo(() => {
if (!error) {
diff --git a/web/tag-farcaster-channel/create-farcaster-channel-tag-modal.react.js b/web/tag-farcaster-channel/create-farcaster-channel-tag-modal.react.js
--- a/web/tag-farcaster-channel/create-farcaster-channel-tag-modal.react.js
+++ b/web/tag-farcaster-channel/create-farcaster-channel-tag-modal.react.js
@@ -33,7 +33,7 @@
const neynarClientContext = React.useContext(NeynarClientContext);
invariant(neynarClientContext, 'NeynarClientContext is missing');
- const { client } = neynarClientContext;
+ const { client, fcCache } = neynarClientContext;
const [channelOptions, setChannelOptions] = React.useState<
$ReadOnlyArray<DropdownOption>,
@@ -89,15 +89,13 @@
}
const channelInfo =
- await neynarClientContext.client.fetchFarcasterChannelByID(
- channelNameText,
- );
+ await fcCache.getFarcasterChannelForChannelID(channelNameText);
if (!channelInfo) {
setError('channel_not_found');
return;
}
createTag(channelInfo.id);
- }, [channelNameText, createTag, neynarClientContext.client, selectedOption]);
+ }, [channelNameText, createTag, fcCache, selectedOption]);
const buttonDisabled =
isLoading ||
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 21, 8:16 AM (5 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2555281
Default Alt Text
D13975.diff (5 KB)
Attached To
Mode
D13975: [keyserver][native][web] Use FCCache instead of calling fetchFarcasterChannelByID directly
Attached
Detach File
Event Timeline
Log In to Comment