Skip to content

Commit

Permalink
fix: deregister tags component when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
arielsvg committed Sep 7, 2020
1 parent 6717907 commit 2055c6d
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions app/assets/javascripts/views/editor/editor_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ class EditorViewCtrl extends PureViewCtrl<{}, EditorState> {
});
}

$onDestroy() {
if (this.state.tagsComponent) {
this.application.componentManager!.deregisterComponent(this.state.tagsComponent.uuid);
}
}

/** @override */
getInitialState() {
return {
Expand Down Expand Up @@ -1058,10 +1064,17 @@ class EditorViewCtrl extends PureViewCtrl<{}, EditorState> {
const [tagsComponent] =
this.application.componentManager!.componentsForArea(ComponentArea.NoteTags);
if (tagsComponent?.uuid !== this.state.tagsComponent?.uuid) {
this.setState({
tagsComponent: tagsComponent?.active ? tagsComponent : undefined
});
if (tagsComponent) {
if (tagsComponent.active) {
this.application.componentManager!.registerComponent(tagsComponent.uuid);
} else {
this.application.componentManager!.deregisterComponent(tagsComponent.uuid);
}
}
}
this.setState({
tagsComponent: tagsComponent?.active ? tagsComponent : undefined
});
this.application.componentManager!.contextItemDidChangeInArea(ComponentArea.NoteTags);
}

Expand Down

0 comments on commit 2055c6d

Please sign in to comment.