chore: cleans up duplicative versions

This commit is contained in:
James
2022-02-09 13:26:20 -05:00
parent e2662336b1
commit 652bd4ab23
2 changed files with 14 additions and 0 deletions

View File

@@ -42,6 +42,13 @@ export const saveCollectionVersion = async ({
});
if (latestVersion) {
// If the latest version is a draft, no need to re-save it
// Example: when "promoting" a draft to published, the draft already exists.
// Instead, return null
if (latestVersion?.version?._status === 'draft') {
return null;
}
version = latestVersion.version;
version = JSON.parse(JSON.stringify(version));
version = sanitizeInternalFields(version);

View File

@@ -37,6 +37,13 @@ export const saveGlobalVersion = async ({
});
if (latestVersion) {
// If the latest version is a draft, no need to re-save it
// Example: when "promoting" a draft to published, the draft already exists.
// Instead, return null
if (latestVersion?.version?._status === 'draft') {
return null;
}
version = latestVersion.version;
version = JSON.parse(JSON.stringify(version));
version = sanitizeInternalFields(version);