Page MenuHomePhabricator

D13983.id45910.diff
No OneTemporary

D13983.id45910.diff

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,9 +37,19 @@
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);
}
}
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

Mime Type
text/plain
Expires
Fri, Nov 22, 5:15 AM (14 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2555299
Default Alt Text
D13983.id45910.diff (2 KB)

Event Timeline