fix: fix outlinePane treeView render only once

This commit is contained in:
橙林 2023-05-17 19:57:15 +08:00 committed by 刘菊萍(絮黎)
parent 059ffe0eaa
commit 8b44ed4429

View File

@ -17,7 +17,9 @@ export class Pane extends PureComponent<{
}> { }> {
private controller; private controller;
private dispose: IPublicTypeDisposable; private simulatorRendererReadyDispose: IPublicTypeDisposable;
private changeDocumentDispose: IPublicTypeDisposable;
private removeDocumentDispose: IPublicTypeDisposable;
constructor(props: any) { constructor(props: any) {
super(props); super(props);
@ -26,16 +28,22 @@ export class Pane extends PureComponent<{
this.state = { this.state = {
tree: treeMaster.currentTree, tree: treeMaster.currentTree,
}; };
this.dispose = this.props.treeMaster.pluginContext?.project?.onSimulatorRendererReady(() => { this.simulatorRendererReadyDispose = this.props.treeMaster.pluginContext?.project?.onSimulatorRendererReady(this.changeTree);
this.setState({ this.changeDocumentDispose = this.props.treeMaster.pluginContext?.project?.onChangeDocument(this.changeTree);
tree: this.props.treeMaster.currentTree, this.removeDocumentDispose = this.props.treeMaster.pluginContext?.project?.onRemoveDocument(this.changeTree);
});
});
} }
changeTree = () => {
this.setState({
tree: this.props.treeMaster.currentTree,
});
};
componentWillUnmount() { componentWillUnmount() {
this.controller.purge(); this.controller.purge();
this.dispose && this.dispose(); this.simulatorRendererReadyDispose?.();
this.changeDocumentDispose?.();
this.removeDocumentDispose?.();
} }
render() { render() {