Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3327127
D13983.id45911.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D13983.id45911.diff
View Options
diff --git a/lib/components/farcaster-channel-prefetch-handler.react.js b/lib/components/farcaster-channel-prefetch-handler.react.js
--- a/lib/components/farcaster-channel-prefetch-handler.react.js
+++ b/lib/components/farcaster-channel-prefetch-handler.react.js
@@ -4,6 +4,7 @@
import { NeynarClientContext } from './neynar-client-provider.react.js';
import { useIsLoggedInToIdentityAndAuthoritativeKeyserver } from '../hooks/account-hooks.js';
+import { getCommunity } from '../shared/thread-utils.js';
import { useCurrentUserFID } from '../utils/farcaster-utils.js';
import { useSelector } from '../utils/redux-utils.js';
@@ -21,6 +22,8 @@
const fcCache = React.useContext(NeynarClientContext)?.fcCache;
const fid = useCurrentUserFID();
+ const rawThreadInfos = useSelector(state => state.threadStore.threadInfos);
+
const communityInfos = useSelector(
state => state.communityStore.communityInfos,
);
@@ -34,10 +37,21 @@
void fcCache.getFollowedFarcasterChannelsForFID(fid);
}
- for (const communityID in communityInfos) {
+ const channelIDs = new Set<string>();
+ for (const threadID in rawThreadInfos) {
+ const threadInfo = rawThreadInfos[threadID];
+ if (threadInfo.avatar?.type !== 'farcaster') {
+ // For now, we only need to prefetch channel info for avatars
+ continue;
+ }
+ const communityID = getCommunity(threadInfo);
+ if (!communityID) {
+ continue;
+ }
const { farcasterChannelID } = communityInfos[communityID];
- if (farcasterChannelID) {
+ if (farcasterChannelID && !channelIDs.has(farcasterChannelID)) {
void fcCache.getFarcasterChannelForChannelID(farcasterChannelID);
+ channelIDs.add(farcasterChannelID);
}
}
// We only want this effect to run when loggedIn or fid change. Its purpose
diff --git a/lib/shared/avatar-utils.js b/lib/shared/avatar-utils.js
--- a/lib/shared/avatar-utils.js
+++ b/lib/shared/avatar-utils.js
@@ -379,7 +379,11 @@
threadAvatarInfo,
params.userProfileInfo,
);
- const farcasterAvatarURL = useFarcasterChannelAvatarURL(fcChannelID);
+ const fcChannelIDToQuery =
+ threadAvatarInfo.type === 'farcaster' && !username && !farcasterID
+ ? fcChannelID
+ : null;
+ const farcasterAvatarURL = useFarcasterChannelAvatarURL(fcChannelIDToQuery);
if (
threadAvatarInfo.type !== 'ens' &&
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 21, 8:17 AM (7 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2555276
Default Alt Text
D13983.id45911.diff (2 KB)
Attached To
Mode
D13983: [lib] Don't query Neynar for Farcaster channel avatars if unused
Attached
Detach File
Event Timeline
Log In to Comment