Skip to content

Commit

Permalink
find the root cause of some jank
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanvorster committed Feb 1, 2023
1 parent e9139e0 commit 557fe74
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
13 changes: 0 additions & 13 deletions packages/core/src/core-models/WorkspaceCollectionModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ export class WorkspaceCollectionModel<
implements WorkspaceCollectionInterface
{
children: WorkspaceModel[];
childrenListeners: Set<() => any>;

constructor(type: string) {
super(type);
this.children = [];
this.childrenListeners = new Set();
}

fromArray(payload: S, engine: WorkspaceEngine) {
Expand Down Expand Up @@ -103,15 +101,6 @@ export class WorkspaceCollectionModel<
return this.children[index + 1];
}

delete() {
// delete all the children
this.childrenListeners.forEach((l) => l());
for (let child of this.children) {
child.delete();
}
super.delete();
}

normalize() {
if (this.parent && this.parent instanceof WorkspaceCollectionModel) {
if (this.children.length === 0) {
Expand Down Expand Up @@ -152,7 +141,6 @@ export class WorkspaceCollectionModel<
const listener = model.registerListener({
removed: () => {
listener();
this.childrenListeners.delete(listener);
this.removeModel(model);
this.iterateListeners((list) => {
list.childRemoved?.(model);
Expand All @@ -165,7 +153,6 @@ export class WorkspaceCollectionModel<
this.invalidateDimensions();
}
});
this.childrenListeners.add(listener);

if (position === null) {
this.children.push(model);
Expand Down
2 changes: 2 additions & 0 deletions packages/defaults/src/DefaultSubComponentRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class DefaultSubComponentRenderer
title={event.model.displayName}
close={() => {
event.model.delete();
event.engine.normalize();
}}
/>
);
Expand All @@ -58,6 +59,7 @@ export class DefaultSubComponentRenderer
title={event.model.displayName}
close={() => {
event.model.parent.delete();
event.engine.normalize();
}}
/>
);
Expand Down

0 comments on commit 557fe74

Please sign in to comment.