diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/workspace/workspace-property/workspace-property.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/workspace/workspace-property/workspace-property.context.ts index 2de1ef1e84..d7cc9578e0 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/workspace/workspace-property/workspace-property.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/workspace/workspace-property/workspace-property.context.ts @@ -144,7 +144,7 @@ export class UmbWorkspacePropertyContext extends UmbBaseControl } public destroy(): void { - this.#data.unsubscribe(); + this.#data.complete(); 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. } } diff --git a/src/Umbraco.Web.UI.Client/src/shared/auth/auth.context.ts b/src/Umbraco.Web.UI.Client/src/shared/auth/auth.context.ts index d17f9e68c9..d01a714e5f 100644 --- a/src/Umbraco.Web.UI.Client/src/shared/auth/auth.context.ts +++ b/src/Umbraco.Web.UI.Client/src/shared/auth/auth.context.ts @@ -2,27 +2,26 @@ import { IUmbAuth } from './auth.interface.js'; import { UmbAuthFlow } from './auth-flow.js'; import { UmbLoggedInUser } from './types.js'; import { UserResource } from '@umbraco-cms/backoffice/backend-api'; -import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; +import { UmbBaseController, UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; import { UmbBooleanState, UmbObjectState } from '@umbraco-cms/backoffice/observable-api'; import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources'; import { firstValueFrom } from '@umbraco-cms/backoffice/external/rxjs'; -export class UmbAuthContext implements IUmbAuth { +export class UmbAuthContext extends UmbBaseController implements IUmbAuth { #currentUser = new UmbObjectState(undefined); readonly currentUser = this.#currentUser.asObservable(); - + readonly isLoggedIn = new UmbBooleanState(false); readonly languageIsoCode = this.#currentUser.asObservablePart((user) => user?.languageIsoCode ?? 'en-us'); - #host; #authFlow; constructor(host: UmbControllerHostElement, serverUrl: string, redirectUrl: string) { - this.#host = host; + super(host) this.#authFlow = new UmbAuthFlow(serverUrl, redirectUrl); - this.isLoggedIn.subscribe((isLoggedIn) => { + this.observe(this.isLoggedIn, (isLoggedIn) => { if (isLoggedIn) { this.fetchCurrentUser(); } @@ -45,7 +44,7 @@ export class UmbAuthContext implements IUmbAuth { } async fetchCurrentUser(): Promise { - const { data } = await tryExecuteAndNotify(this.#host, UserResource.getUserCurrent()); + const { data } = await tryExecuteAndNotify(this._host, UserResource.getUserCurrent()); this.#currentUser.next(data);