Skip to content

Commit

Permalink
Fix profile setup showing default avatar in web UI (mastodon#28453)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron authored Dec 21, 2023
1 parent d29b1cc commit 01f0a6c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/javascript/mastodon/features/onboarding/profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const messages = defineMessages({
uploadAvatar: { id: 'onboarding.profile.upload_avatar', defaultMessage: 'Upload profile picture' },
});

const nullIfMissing = path => path.endsWith('missing.png') ? null : path;

export const Profile = () => {
const account = useAppSelector(state => state.getIn(['accounts', me]));
const [displayName, setDisplayName] = useState(account.get('display_name'));
Expand Down Expand Up @@ -61,8 +63,8 @@ export const Profile = () => {
setHeader(e.target?.files?.[0]);
}, [setHeader]);

const avatarPreview = useMemo(() => avatar ? URL.createObjectURL(avatar) : account.get('avatar'), [avatar, account]);
const headerPreview = useMemo(() => header ? URL.createObjectURL(header) : account.get('header'), [header, account]);
const avatarPreview = useMemo(() => avatar ? URL.createObjectURL(avatar) : nullIfMissing(account.get('avatar')), [avatar, account]);
const headerPreview = useMemo(() => header ? URL.createObjectURL(header) : nullIfMissing(account.get('header')), [header, account]);

const handleSubmit = useCallback(() => {
setIsSaving(true);
Expand Down

0 comments on commit 01f0a6c

Please sign in to comment.