diff --git a/app/composables/useFiles.ts b/app/composables/useFiles.ts index 0c05b67..18409f9 100644 --- a/app/composables/useFiles.ts +++ b/app/composables/useFiles.ts @@ -134,8 +134,16 @@ export default function useFiles() { return acc }, {}) + // Remove fields from original metadata if they're empty in the update + const fileMetadataWithRemovedFields = Object.entries(file.metadata).reduce>((acc, [key, value]) => { + if (key in strippedMappedMetadata) { + acc[key] = value + } + return acc + }, {}) + const updatedMetadata = { - ...file.metadata, + ...fileMetadataWithRemovedFields, ...strippedMappedMetadata, // Automatically set originating program and version using values from package.json ...(originatingProgram ? { '2:65': originatingProgram } : {}),