From 122dd90c37b2d9863f9038dc0cf468cd283cb3aa Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 7 Dec 2023 11:51:34 +0100 Subject: [PATCH] add null check for data --- .../workspace/document-type-workspace.context.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/document-types/workspace/document-type-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/document-types/workspace/document-type-workspace.context.ts index c39891181c..512335792d 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/document-types/workspace/document-type-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/document-types/workspace/document-type-workspace.context.ts @@ -77,11 +77,11 @@ export class UmbDocumentTypeWorkspaceContext } getData() { - return this.structure.getOwnerContentType() || {}; + return this.structure.getOwnerContentType(); } getEntityId() { - return this.getData().id; + return this.getData()?.id; } getEntityType() { @@ -154,6 +154,9 @@ export class UmbDocumentTypeWorkspaceContext * Save or creates the document type, based on wether its a new one or existing. */ async save() { + const data = this.getData(); + if (data === undefined) throw new Error('Cannot save, no data'); + if (this.getIsNew()) { if ((await this.structure.create()) === true) { this.setIsNew(false); @@ -162,7 +165,7 @@ export class UmbDocumentTypeWorkspaceContext await this.structure.save(); } - this.saveComplete(this.getData()); + this.saveComplete(data); } public destroy(): void {