don't allow empty constructs of node context

This commit is contained in:
Mads Rasmussen
2022-08-05 19:10:55 +02:00
parent 66fe308a6e
commit f9922a193c
2 changed files with 8 additions and 5 deletions

View File

@@ -59,7 +59,7 @@ export class UmbEditorNodeElement extends UmbContextProviderMixin(UmbContextCons
private _nodeStore?: UmbNodeStore;
private _nodeStoreSubscription?: Subscription;
private _nodeContext = new UmbNodeContext();
private _nodeContext?: UmbNodeContext;
private _nodeContextSubscription?: Subscription;
private _notificationService?: UmbNotificationService;
@@ -77,8 +77,6 @@ export class UmbEditorNodeElement extends UmbContextProviderMixin(UmbContextCons
});
this.addEventListener('property-value-change', this._onPropertyValueChange);
this.provideContext('umbNodeContext', this._nodeContext);
}
private _onPropertyValueChange = (e: Event) => {
@@ -109,7 +107,12 @@ export class UmbEditorNodeElement extends UmbContextProviderMixin(UmbContextCons
this._nodeContextSubscription?.unsubscribe();
this._nodeContext?.update(node);
if (!this._nodeContext) {
this._nodeContext = new UmbNodeContext(node);
this.provideContext('umbNodeContext', this._nodeContext);
} else {
this._nodeContext.update(node);
}
this._nodeContextSubscription = this._nodeContext.data.pipe(distinctUntilChanged()).subscribe((data) => {
this._node = data;

View File

@@ -26,7 +26,7 @@ export class UmbNodeContext {
});
public readonly data: Observable<NodeEntity> = this._data.asObservable();
constructor(node?: NodeEntity) {
constructor(node: NodeEntity) {
if (!node) return;
this._data.next(node);
}