Skip to content

Commit 6b94a20

Browse files
committed
dispatch event from detail-workspace-base
1 parent 0b5e760 commit 6b94a20

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/Umbraco.Web.UI.Client/src/packages/core/workspace/entity-detail/entity-detail-workspace-base.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ export abstract class UmbEntityDetailWorkspaceContextBase<
9595

9696
this.#eventContext.removeEventListener(
9797
UmbEntityUpdatedEvent.TYPE,
98-
this.#onEntityDetailUpdatedEvent as unknown as EventListener,
98+
this.#onEntityUpdatedEvent as unknown as EventListener,
9999
);
100100
this.#eventContext.addEventListener(
101101
UmbEntityUpdatedEvent.TYPE,
102-
this.#onEntityDetailUpdatedEvent as unknown as EventListener,
102+
this.#onEntityUpdatedEvent as unknown as EventListener,
103103
);
104104
});
105105
}
@@ -324,13 +324,21 @@ export abstract class UmbEntityDetailWorkspaceContextBase<
324324
this._data.setPersisted(data);
325325
this._data.setCurrent(data);
326326

327-
const actionEventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);
328-
const event = new UmbRequestReloadStructureForEntityEvent({
329-
unique: this.getUnique()!,
330-
entityType: this.getEntityType(),
327+
const unique = this.getUnique()!;
328+
const entityType = this.getEntityType();
329+
330+
const eventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);
331+
const event = new UmbRequestReloadStructureForEntityEvent({ unique, entityType });
332+
333+
eventContext.dispatchEvent(event);
334+
335+
const updatedEvent = new UmbEntityUpdatedEvent({
336+
unique,
337+
entityType,
338+
discriminator: this._workspaceEventDiscriminator,
331339
});
332340

333-
actionEventContext.dispatchEvent(event);
341+
eventContext.dispatchEvent(updatedEvent);
334342
}
335343

336344
#allowNavigateAway = false;
@@ -416,7 +424,7 @@ export abstract class UmbEntityDetailWorkspaceContextBase<
416424
// Discriminator to identify events from this workspace context
417425
protected readonly _workspaceEventDiscriminator = UmbId.new();
418426

419-
#onEntityDetailUpdatedEvent = (event: UmbEntityUpdatedEvent) => {
427+
#onEntityUpdatedEvent = (event: UmbEntityUpdatedEvent) => {
420428
const eventEntityUnique = event.getUnique();
421429
const eventEntityType = event.getEntityType();
422430
const eventDiscriminator = event.getDiscriminator();
@@ -435,7 +443,7 @@ export abstract class UmbEntityDetailWorkspaceContextBase<
435443
window.removeEventListener('willchangestate', this.#onWillNavigate);
436444
this.#eventContext?.removeEventListener(
437445
UmbEntityUpdatedEvent.TYPE,
438-
this.#onEntityDetailUpdatedEvent as unknown as EventListener,
446+
this.#onEntityUpdatedEvent as unknown as EventListener,
439447
);
440448
this._detailRepository?.destroy();
441449
this.#entityContext.destroy();

0 commit comments

Comments
 (0)