Skip to content

Commit

Permalink
tidy(ui): clean up awkward selector in CanvasEntityAdapterBase
Browse files Browse the repository at this point in the history
  • Loading branch information
psychedelicious committed Oct 8, 2024
1 parent 20ae8ee commit 752e2b7
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export abstract class CanvasEntityAdapterBase<
*/
abstract getHashableState: () => SerializableObject;

private _selectIsHidden: Selector<RootState, boolean> | null = null;
selectIsHidden: Selector<RootState, boolean>;

/**
* The Konva nodes that make up the entity adapter:
Expand Down Expand Up @@ -171,6 +171,8 @@ export abstract class CanvasEntityAdapterBase<
assert(state !== undefined, 'Missing entity state on creation');
this.state = state;

this.selectIsHidden = buildEntityIsHiddenSelector(this.entityIdentifier);

/**
* There are a number of reason we may need to show or hide a layer:
* - The entity is enabled/disabled
Expand Down Expand Up @@ -224,14 +226,6 @@ export abstract class CanvasEntityAdapterBase<
*/
selectPosition = createSelector(this.selectState, (entity) => entity?.position);

get selectIsHidden() {
// This must be a getter because the selector depends on the entityIdentifier, which is set in the constructor.
if (!this._selectIsHidden) {
this._selectIsHidden = buildEntityIsHiddenSelector(this.entityIdentifier);
}
return this._selectIsHidden;
}

syncIsOnscreen = () => {
const stageRect = this.manager.stage.getScaledStageRect();
const entityRect = this.transformer.$pixelRect.get();
Expand Down

0 comments on commit 752e2b7

Please sign in to comment.