Page MenuHomePhabricator

D13722.id45248.diff
No OneTemporary

D13722.id45248.diff

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
@@ -319,8 +319,8 @@
return getDefaultAvatar(thread.id, thread.color);
}
-function useResolvedAvatar(
- avatarInfo: ClientAvatar,
+function useResolvedUserAvatar(
+ userAvatarInfo: ClientAvatar,
usernameAndFID: ?{ +username?: ?string, +farcasterID?: ?string, ... },
): ResolvedClientAvatar {
const ethAddress = React.useMemo(
@@ -334,8 +334,8 @@
const farcasterAvatarURL = useFarcasterAvatarURL(fid);
const resolvedAvatar = React.useMemo(() => {
- if (avatarInfo.type !== 'ens' && avatarInfo.type !== 'farcaster') {
- return avatarInfo;
+ if (userAvatarInfo.type !== 'ens' && userAvatarInfo.type !== 'farcaster') {
+ return userAvatarInfo;
}
if (ensAvatarURI) {
@@ -351,11 +351,30 @@
}
return defaultAnonymousUserEmojiAvatar;
- }, [avatarInfo, ensAvatarURI, farcasterAvatarURL]);
+ }, [userAvatarInfo, ensAvatarURI, farcasterAvatarURL]);
return resolvedAvatar;
}
+function useResolvedThreadAvatar(
+ threadAvatarInfo: ClientAvatar,
+ displayUser: ?{ +username?: ?string, +farcasterID?: ?string, ... },
+): ResolvedClientAvatar {
+ const resolvedUserAvatar = useResolvedUserAvatar(
+ threadAvatarInfo,
+ displayUser,
+ );
+
+ if (
+ threadAvatarInfo.type !== 'ens' &&
+ threadAvatarInfo.type !== 'farcaster'
+ ) {
+ return threadAvatarInfo;
+ }
+
+ return resolvedUserAvatar;
+}
+
export {
defaultAnonymousUserEmojiAvatar,
defaultEmojiAvatars,
@@ -364,5 +383,6 @@
getAvatarForUser,
getUserAvatarForThread,
getAvatarForThread,
- useResolvedAvatar,
+ useResolvedUserAvatar,
+ useResolvedThreadAvatar,
};
diff --git a/native/avatars/thread-avatar.react.js b/native/avatars/thread-avatar.react.js
--- a/native/avatars/thread-avatar.react.js
+++ b/native/avatars/thread-avatar.react.js
@@ -3,7 +3,7 @@
import * as React from 'react';
import { useAvatarForThread } from 'lib/hooks/avatar-hooks.js';
-import { useResolvedAvatar } from 'lib/shared/avatar-utils.js';
+import { useResolvedThreadAvatar } from 'lib/shared/avatar-utils.js';
import { getSingleOtherUser } from 'lib/shared/thread-utils.js';
import type { AvatarSize } from 'lib/types/avatar-types.js';
import type {
@@ -55,7 +55,7 @@
};
});
- const resolvedThreadAvatar = useResolvedAvatar(avatarInfo, displayUser);
+ const resolvedThreadAvatar = useResolvedThreadAvatar(avatarInfo, displayUser);
return <Avatar size={size} avatarInfo={resolvedThreadAvatar} />;
}
diff --git a/native/avatars/user-avatar.react.js b/native/avatars/user-avatar.react.js
--- a/native/avatars/user-avatar.react.js
+++ b/native/avatars/user-avatar.react.js
@@ -4,7 +4,7 @@
import {
getAvatarForUser,
- useResolvedAvatar,
+ useResolvedUserAvatar,
} from 'lib/shared/avatar-utils.js';
import type {
GenericUserInfoWithAvatar,
@@ -47,7 +47,7 @@
const avatar = getAvatarForUser(userAvatarInfo);
- const resolvedUserAvatar = useResolvedAvatar(avatar, userAvatarInfo);
+ const resolvedUserAvatar = useResolvedUserAvatar(avatar, userAvatarInfo);
return <Avatar size={size} avatarInfo={resolvedUserAvatar} />;
}
diff --git a/web/avatars/thread-avatar.react.js b/web/avatars/thread-avatar.react.js
--- a/web/avatars/thread-avatar.react.js
+++ b/web/avatars/thread-avatar.react.js
@@ -3,7 +3,7 @@
import * as React from 'react';
import { useAvatarForThread } from 'lib/hooks/avatar-hooks.js';
-import { useResolvedAvatar } from 'lib/shared/avatar-utils.js';
+import { useResolvedThreadAvatar } from 'lib/shared/avatar-utils.js';
import { getSingleOtherUser } from 'lib/shared/thread-utils.js';
import type { AvatarSize } from 'lib/types/avatar-types.js';
import type {
@@ -55,7 +55,7 @@
};
});
- const resolvedThreadAvatar = useResolvedAvatar(avatarInfo, displayUser);
+ const resolvedThreadAvatar = useResolvedThreadAvatar(avatarInfo, displayUser);
return (
<Avatar
diff --git a/web/avatars/user-avatar.react.js b/web/avatars/user-avatar.react.js
--- a/web/avatars/user-avatar.react.js
+++ b/web/avatars/user-avatar.react.js
@@ -4,7 +4,7 @@
import {
getAvatarForUser,
- useResolvedAvatar,
+ useResolvedUserAvatar,
} from 'lib/shared/avatar-utils.js';
import type { AvatarSize } from 'lib/types/avatar-types.js';
import { useCurrentUserFID } from 'lib/utils/farcaster-utils.js';
@@ -40,7 +40,7 @@
const avatar = getAvatarForUser(userAvatarInfo);
- const resolvedUserAvatar = useResolvedAvatar(avatar, userAvatarInfo);
+ const resolvedUserAvatar = useResolvedUserAvatar(avatar, userAvatarInfo);
return (
<Avatar

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 20, 7:17 AM (21 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2543368
Default Alt Text
D13722.id45248.diff (4 KB)

Event Timeline