From a7bad8f45cad39df7c18eb57b9df18304b799a1e Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 21 Dec 2023 09:32:25 +0100 Subject: [PATCH] [Glitch] Fix profile setup showing default avatar in web UI Port 01f0a6ca4fbb4d53c01f8be353a9ebfeb98f1739 to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/features/onboarding/profile.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/javascript/flavours/glitch/features/onboarding/profile.jsx b/app/javascript/flavours/glitch/features/onboarding/profile.jsx index fd045009ab..fb7c515f00 100644 --- a/app/javascript/flavours/glitch/features/onboarding/profile.jsx +++ b/app/javascript/flavours/glitch/features/onboarding/profile.jsx @@ -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')); @@ -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);