refactor: improve cover image upload handling and documentation

- Updated comments in the cover image helper to clarify the upload process for local static images.
- Simplified the return logic for both user and project assets, ensuring immediate UI feedback with the uploaded URL.
- Enhanced clarity on how the backend auto-links assets based on the entity identifier.
This commit is contained in:
Jayash Tripathy
2025-12-03 16:18:32 +05:30
parent 801466e018
commit ec51b4f6a8
+10 -14
View File
@@ -255,25 +255,21 @@ export const handleCoverImageChange = async (
};
}
// Local static image - needs upload
// Local static image - needs upload first
if (analysis.needsUpload) {
const uploadedUrl = await uploadCoverImage(newImage, uploadConfig);
// For BOTH user assets AND project assets:
// The backend auto-links when entity_identifier is set correctly
// For project assets: auto-linked server-side, no payload needed
// For user assets: return URL for immediate UI feedback
if (uploadConfig.isUserAsset) {
return {
cover_image_url: uploadedUrl,
};
} else {
return null;
}
// Backend auto-links the asset when entity_identifier is set correctly.
// We still return the URL for immediate UI feedback regardless of asset type.
return {
cover_image_url: uploadedUrl,
};
}
return null;
// Already an uploaded URL (e.g., from Unsplash or gallery) - just update the reference
return {
cover_image_url: newImage,
};
};
/**