From a0ab0e86883f80bd3c17cef0e407e17ec2bffa60 Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Tue, 26 Aug 2025 15:33:35 -0500 Subject: [PATCH] Don't fetch all logos when uploading a new logo. --- frontend/src/components/forms/Logo.jsx | 9 ++++----- frontend/src/components/tables/LogosTable.jsx | 5 +++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/forms/Logo.jsx b/frontend/src/components/forms/Logo.jsx index a9459062..25847ce8 100644 --- a/frontend/src/components/forms/Logo.jsx +++ b/frontend/src/components/forms/Logo.jsx @@ -52,14 +52,12 @@ const LogoForm = ({ logo = null, isOpen, onClose, onSuccess }) => { onSubmit: async (values, { setSubmitting }) => { try { setUploading(true); + let uploadResponse = null; // Store upload response for later use // If we have a selected file, upload it first if (selectedFile) { try { - const uploadResponse = await API.uploadLogo( - selectedFile, - values.name - ); + uploadResponse = await API.uploadLogo(selectedFile, values.name); // Use the uploaded file data instead of form values values.name = uploadResponse.name; values.url = uploadResponse.url; @@ -108,12 +106,13 @@ const LogoForm = ({ logo = null, isOpen, onClose, onSuccess }) => { onSuccess?.({ type: 'create', logo: newLogo }); // Call onSuccess for creates } else { // File was uploaded and logo was already created + // Note: API.uploadLogo already calls addLogo() in the store, so no need to call onSuccess notifications.show({ title: 'Success', message: 'Logo uploaded successfully', color: 'green', }); - onSuccess?.({ type: 'upload' }); // Call onSuccess for uploads + // No onSuccess call needed - API.uploadLogo already updated the store } onClose(); } catch (error) { diff --git a/frontend/src/components/tables/LogosTable.jsx b/frontend/src/components/tables/LogosTable.jsx index 237434e9..ac0a975d 100644 --- a/frontend/src/components/tables/LogosTable.jsx +++ b/frontend/src/components/tables/LogosTable.jsx @@ -548,11 +548,12 @@ const LogosTable = () => { if (type === 'update' && logo) { // For updates, just update the specific logo in the store updateLogo(logo); - } else if (type === 'create' && logo) { + } else if ((type === 'create' || type === 'upload') && logo) { // For creates, add the new logo to the store + // Note: uploads are handled automatically by API.uploadLogo, so this path is rarely used addLogo(logo); } else { - // For uploads or when we don't have logo data, refresh all + // Fallback: if we don't have logo data for some reason, refresh all await fetchAllLogos(); // Use fetchAllLogos to maintain full view } },