MCPcopy Create free account
hub / github.com/CommE2E/comm / useDisplayUserForThread

Function useDisplayUserForThread

lib/shared/avatar-utils.js:427–452  ·  view source on GitHub ↗
(
  displayUserIDForThread: ?string,
  userInfos: UserInfos,
  auxUserInfos: { +[userID: string]: { +fid?: ?string, ... }, ... },
)

Source from the content-addressed store, hash-verified

425}
426
427function useDisplayUserForThread(
428 displayUserIDForThread: ?string,
429 userInfos: UserInfos,
430 auxUserInfos: { +[userID: string]: { +fid?: ?string, ... }, ... },
431): ?UsernameAndFID {
432 return React.useMemo(() => {
433 if (!displayUserIDForThread) {
434 return null;
435 }
436
437 const fid = extractFIDFromUserID(displayUserIDForThread);
438 if (fid) {
439 return {
440 farcasterID: fid,
441 };
442 }
443
444 const userBase = userInfos[displayUserIDForThread];
445 const farcasterID = auxUserInfos[displayUserIDForThread]?.fid;
446
447 return {
448 ...userBase,
449 farcasterID,
450 };
451 }, [displayUserIDForThread, userInfos, auxUserInfos]);
452}
453
454export {
455 defaultAnonymousUserEmojiAvatar,

Callers 2

ThreadAvatarFunction · 0.90

Calls 1

extractFIDFromUserIDFunction · 0.90

Tested by

no test coverage detected