Skip to content

Commit

Permalink
[web] display farcaster avatar when it's set
Browse files Browse the repository at this point in the history
Summary:
in D13380 I made it possible to set a farcaster avatar from web. however after refactoring D13101, we won't actually display this avatar from the settings page when it's set without the changes in this diff

Depends on D13381

Test Plan: tested by setting and unsetting all avatar types from settings page on web

Reviewers: ashoat, tomek

Reviewed By: ashoat

Differential Revision: https://phab.comm.dev/D13456
  • Loading branch information
vdhanan committed Sep 25, 2024
1 parent 0332be8 commit faee4b8
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions web/avatars/user-avatar.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
useResolvedAvatar,
} from 'lib/shared/avatar-utils.js';
import type { AvatarSize } from 'lib/types/avatar-types.js';
import { useCurrentUserFID } from 'lib/utils/farcaster-utils.js';

import Avatar from './avatar.react.js';
import { useSelector } from '../redux/redux-utils.js';
Expand All @@ -20,12 +21,26 @@ type Props = {
function UserAvatar(props: Props): React.Node {
const { userID, size, showSpinner } = props;

const userInfo = useSelector(state =>
userID ? state.userStore.userInfos[userID] : null,
);
const avatarInfo = getAvatarForUser(userInfo);

const resolvedUserAvatar = useResolvedAvatar(avatarInfo, userInfo);
const currentUserFID = useCurrentUserFID();
const userAvatarInfo = useSelector(state => {
if (!userID) {
return null;
} else if (userID === state.currentUserInfo?.id) {
return {
...state.currentUserInfo,
farcasterID: currentUserFID,
};
} else {
return {
...state.userStore.userInfos[userID],
farcasterID: state.auxUserStore.auxUserInfos[userID]?.fid,
};
}
});

const avatar = getAvatarForUser(userAvatarInfo);

const resolvedUserAvatar = useResolvedAvatar(avatar, userAvatarInfo);

return (
<Avatar
Expand Down

0 comments on commit faee4b8

Please sign in to comment.