(
threadAvatarInfo: ClientAvatar,
params: {
+userProfileInfo: ?UsernameAndFID,
+channelInfo: FCChannelInfo,
},
)
| 375 | } |
| 376 | |
| 377 | function useResolvedThreadAvatar( |
| 378 | threadAvatarInfo: ClientAvatar, |
| 379 | params: { |
| 380 | +userProfileInfo: ?UsernameAndFID, |
| 381 | +channelInfo: FCChannelInfo, |
| 382 | }, |
| 383 | ): ResolvedClientAvatar { |
| 384 | const username = params.userProfileInfo?.username; |
| 385 | const farcasterID = params.userProfileInfo?.farcasterID; |
| 386 | const fcChannelID = params.channelInfo.fcChannelID; |
| 387 | |
| 388 | const resolvedUserAvatar = useResolvedUserAvatar( |
| 389 | threadAvatarInfo, |
| 390 | params.userProfileInfo, |
| 391 | ); |
| 392 | const fcChannelIDToQuery = |
| 393 | threadAvatarInfo.type === 'farcaster' && !username && !farcasterID |
| 394 | ? fcChannelID |
| 395 | : null; |
| 396 | const farcasterAvatarURL = useFarcasterChannelAvatarURL(fcChannelIDToQuery); |
| 397 | |
| 398 | if ( |
| 399 | threadAvatarInfo.type !== 'ens' && |
| 400 | threadAvatarInfo.type !== 'farcaster' |
| 401 | ) { |
| 402 | return threadAvatarInfo; |
| 403 | } |
| 404 | |
| 405 | // If both `userProfileInfo` and `channelInfo` are supplied, the former should |
| 406 | // supersede the latter. |
| 407 | if (username || farcasterID) { |
| 408 | return resolvedUserAvatar; |
| 409 | } |
| 410 | |
| 411 | if (farcasterAvatarURL) { |
| 412 | return { |
| 413 | type: 'image', |
| 414 | uri: farcasterAvatarURL, |
| 415 | }; |
| 416 | } |
| 417 | |
| 418 | // If fetching a Farcaster channel avatar URL fails or is in-progress, we |
| 419 | // return a default anonymous avatar |
| 420 | return { |
| 421 | type: 'emoji', |
| 422 | color: selectedThreadColors[4], |
| 423 | emoji: '👥', |
| 424 | }; |
| 425 | } |
| 426 | |
| 427 | function useDisplayUserForThread( |
| 428 | displayUserIDForThread: ?string, |
no test coverage detected