Fix profile setup showing default avatar in web UI (#28453)

This commit is contained in:
Eugen Rochko 2023-12-21 09:32:25 +01:00 committed by GitHub
parent d29b1cca2e
commit 01f0a6ca4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -26,6 +26,8 @@ const messages = defineMessages({
uploadAvatar: { id: 'onboarding.profile.upload_avatar', defaultMessage: 'Upload profile picture' }, uploadAvatar: { id: 'onboarding.profile.upload_avatar', defaultMessage: 'Upload profile picture' },
}); });
const nullIfMissing = path => path.endsWith('missing.png') ? null : path;
export const Profile = () => { export const Profile = () => {
const account = useAppSelector(state => state.getIn(['accounts', me])); const account = useAppSelector(state => state.getIn(['accounts', me]));
const [displayName, setDisplayName] = useState(account.get('display_name')); const [displayName, setDisplayName] = useState(account.get('display_name'));
@ -61,8 +63,8 @@ export const Profile = () => {
setHeader(e.target?.files?.[0]); setHeader(e.target?.files?.[0]);
}, [setHeader]); }, [setHeader]);
const avatarPreview = useMemo(() => avatar ? URL.createObjectURL(avatar) : account.get('avatar'), [avatar, account]); const avatarPreview = useMemo(() => avatar ? URL.createObjectURL(avatar) : nullIfMissing(account.get('avatar')), [avatar, account]);
const headerPreview = useMemo(() => header ? URL.createObjectURL(header) : account.get('header'), [header, account]); const headerPreview = useMemo(() => header ? URL.createObjectURL(header) : nullIfMissing(account.get('header')), [header, account]);
const handleSubmit = useCallback(() => { const handleSubmit = useCallback(() => {
setIsSaving(true); setIsSaving(true);