Fix remove avatar (#603)

This commit is contained in:
Chris 2025-11-27 18:12:23 +02:00 committed by GitHub
parent 901933f4f1
commit 46374b2026
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 9 deletions

View file

@ -7,7 +7,7 @@ services:
- TUDUDI_USER_PASSWORD=your-secure-password
- TUDUDI_SESSION_SECRET=changeme-please-use-openssl
- TUDUDI_ALLOWED_ORIGINS=http://localhost:3002
- TUDUDI_UPLOAD_PATH="/app/backend/uploads"
- TUDUDI_UPLOAD_PATH=/app/backend/uploads
# Runtime UID/GID configuration - set these to match your host user/group
- PUID=1001
- PGID=1001

View file

@ -789,10 +789,25 @@ const ProfileSettings: React.FC<ProfileSettingsProps> = ({
reader.readAsDataURL(file);
};
const handleAvatarRemove = () => {
setAvatarFile(null);
setAvatarPreview(null);
setRemoveAvatar(true);
const handleAvatarRemove = async () => {
try {
await deleteAvatar();
setAvatarFile(null);
setAvatarPreview(null);
setRemoveAvatar(false);
setFormData((prev) => ({ ...prev, avatar_image: '' }));
if (profile) {
setProfile({ ...profile, avatar_image: null });
}
showSuccessToast('Avatar removed successfully');
} catch (error) {
showErrorToast(
(error as Error).message || 'Failed to remove avatar'
);
}
};
const uploadAvatar = async (file: File): Promise<string> => {
@ -872,11 +887,9 @@ const ProfileSettings: React.FC<ProfileSettingsProps> = ({
updatedProfile.avatar_image = avatarUrl;
setAvatarFile(null);
setAvatarPreview(null);
} else if (removeAvatar && formData.avatar_image) {
await deleteAvatar();
updatedProfile.avatar_image = null;
setRemoveAvatar(false);
}
// Avatar removal is now handled immediately by handleAvatarRemove
// No need to handle it here anymore
setProfile(updatedProfile);