From 6bf42d5a44a568eeb5f12e134dbedfa2b421d3b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Thu, 22 Feb 2024 13:27:13 +0100 Subject: [PATCH] more destroying --- .../src/libs/class-api/context-base.class.ts | 11 +++++++---- .../src/libs/class-api/context.interface.ts | 3 +++ src/Umbraco.Web.UI.Client/src/libs/class-api/index.ts | 1 + .../libs/localization-api/localization.controller.ts | 1 + .../core/modal/modal-route-registration.controller.ts | 6 +++++- .../property-dataset-context.interface.ts | 5 ++--- .../core/property/property/property.context.ts | 2 ++ 7 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/libs/class-api/context.interface.ts diff --git a/src/Umbraco.Web.UI.Client/src/libs/class-api/context-base.class.ts b/src/Umbraco.Web.UI.Client/src/libs/class-api/context-base.class.ts index d299c3a9af..cb4440e022 100644 --- a/src/Umbraco.Web.UI.Client/src/libs/class-api/context-base.class.ts +++ b/src/Umbraco.Web.UI.Client/src/libs/class-api/context-base.class.ts @@ -1,5 +1,6 @@ import type { UmbContextToken } from '../context-api/index.js'; import type { UmbControllerHost } from '../controller-api/index.js'; +import type { UmbContext } from './context.interface.js'; import { UmbBaseController } from './controller-base.class.js'; /** @@ -7,10 +8,12 @@ import { UmbBaseController } from './controller-base.class.js'; * */ export abstract class UmbContextBase< - ContextType, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - GivenContextToken extends UmbContextToken = UmbContextToken, -> extends UmbBaseController { + ContextType, + GivenContextToken extends UmbContextToken = UmbContextToken, + > + extends UmbBaseController + implements UmbContext +{ constructor(host: UmbControllerHost, contextToken: GivenContextToken | string) { super(host, contextToken.toString()); this.provideContext(contextToken, this as unknown as ContextType); diff --git a/src/Umbraco.Web.UI.Client/src/libs/class-api/context.interface.ts b/src/Umbraco.Web.UI.Client/src/libs/class-api/context.interface.ts new file mode 100644 index 0000000000..23181093ad --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/libs/class-api/context.interface.ts @@ -0,0 +1,3 @@ +import type { UmbController } from '../controller-api/controller.interface.js'; + +export interface UmbContext extends UmbController {} diff --git a/src/Umbraco.Web.UI.Client/src/libs/class-api/index.ts b/src/Umbraco.Web.UI.Client/src/libs/class-api/index.ts index 72155e8b3b..dd4339f71f 100644 --- a/src/Umbraco.Web.UI.Client/src/libs/class-api/index.ts +++ b/src/Umbraco.Web.UI.Client/src/libs/class-api/index.ts @@ -1,4 +1,5 @@ export * from './class.interface.js'; export * from './class.mixin.js'; +export * from './context.interface.js'; export * from './context-base.class.js'; export * from './controller-base.class.js'; diff --git a/src/Umbraco.Web.UI.Client/src/libs/localization-api/localization.controller.ts b/src/Umbraco.Web.UI.Client/src/libs/localization-api/localization.controller.ts index 5b22a70ada..8804fdf918 100644 --- a/src/Umbraco.Web.UI.Client/src/libs/localization-api/localization.controller.ts +++ b/src/Umbraco.Web.UI.Client/src/libs/localization-api/localization.controller.ts @@ -65,6 +65,7 @@ export class UmbLocalizationController UmbVariantId; @@ -26,8 +27,6 @@ export interface UmbPropertyDatasetContext { // Should it be possible to get the properties as a list of property aliases? //readonly properties: Observable>; - destroy(): void; - // Property methods: propertyVariantId?: (propertyAlias: string) => Promise>; propertyValueByAlias(propertyAlias: string): Promise>; diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property/property/property.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property/property/property.context.ts index e39b92fe95..2ffca7f917 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/property/property/property.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property/property/property.context.ts @@ -148,6 +148,7 @@ export class UmbPropertyContext extends UmbBaseController { } public destroy(): void { + super.destroy(); this.#alias.destroy(); this.#label.destroy(); this.#description.destroy(); @@ -155,6 +156,7 @@ export class UmbPropertyContext extends UmbBaseController { this.#value.destroy(); this.#configCollection.destroy(); this._providerController.destroy(); // This would also be handled by the controller host, but if someone wanted to replace/remove this context without the host being destroyed. Then we have clean up out selfs here. + this.#datasetContext = undefined; } }