chore: apply suggested changes

Co-authored-by: phunguyenmurcul <51897872+phunguyenmurcul@users.noreply.github.com>
This commit is contained in:
gitstart 2023-06-28 16:05:47 +00:00
parent e6e3ab455c
commit f9306e3e8d

View File

@ -157,13 +157,14 @@ const generateAPI = ({ singularName, kind = 'collectionType', pluralName, displa
const editContentType = async (uid, { contentType, components = [] }) => { const editContentType = async (uid, { contentType, components = [] }) => {
const builder = createBuilder(); const builder = createBuilder();
const previousKind = builder.contentTypes.get(uid).schema.kind; const previousSchema = builder.contentTypes.get(uid).schema;
const previousKind = previousSchema.kind;
const newKind = contentType.kind || previousKind; const newKind = contentType.kind || previousKind;
// Restore non-visible attributes from previous schema // Restore non-visible attributes from previous schema
const previousAttributes = builder.contentTypes.get(uid).schema.attributes; const previousAttributes = previousSchema.attributes;
const prevNonVisibleAttributes = contentTypesUtils const prevNonVisibleAttributes = contentTypesUtils
.getNonVisibleAttributes(builder.contentTypes.get(uid).schema) .getNonVisibleAttributes(previousSchema)
.reduce((acc, key) => { .reduce((acc, key) => {
if (key in previousAttributes) { if (key in previousAttributes) {
acc[key] = previousAttributes[key]; acc[key] = previousAttributes[key];