mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-08-03 07:12:30 +00:00
Don't fetch all logos when uploading a new logo.
This commit is contained in:
parent
2645166c8c
commit
a0ab0e8688
2 changed files with 7 additions and 7 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue