Update use status api with mount event
This commit is contained in:
@@ -41,7 +41,6 @@ class ObjectCommand extends Component<IMixinStatusProps> {
|
||||
className="command-item"
|
||||
onClick={() => {
|
||||
this.props.status ? this.props.status.newGroup() : undefined;
|
||||
this.props.status ? this.props.status.model.draw() : undefined;
|
||||
}}
|
||||
>
|
||||
<Icon iconName="WebAppBuilderFragmentCreate"></Icon>
|
||||
@@ -50,7 +49,6 @@ class ObjectCommand extends Component<IMixinStatusProps> {
|
||||
className="command-item"
|
||||
onClick={() => {
|
||||
this.props.status ? this.props.status.newRange() : undefined;
|
||||
this.props.status ? this.props.status.model.draw() : undefined;
|
||||
}}
|
||||
>
|
||||
<Icon iconName="CubeShape"></Icon>
|
||||
@@ -65,7 +63,6 @@ class ObjectCommand extends Component<IMixinStatusProps> {
|
||||
})
|
||||
this.props.status.model.deleteObject(deleteId);
|
||||
this.props.status.setFocusObject(new Set<ObjectID>());
|
||||
this.props.status.model.draw();
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -1,33 +1,15 @@
|
||||
import { Component, ReactNode } from "react";
|
||||
import { DetailsList } from "@Component/DetailsList/DetailsList";
|
||||
import { useStatus, IMixinStatusProps } from "@Context/Status";
|
||||
import { useStatusWithEvent, IMixinStatusProps } from "@Context/Status";
|
||||
import { useSetting, IMixinSettingProps } from "@Context/Setting";
|
||||
import { Localization } from "@Component/Localization/Localization";
|
||||
import { ObjectID } from "@Model/Renderer";
|
||||
import "./ObjectList.scss";
|
||||
|
||||
@useSetting
|
||||
@useStatus
|
||||
@useStatusWithEvent("objectChange", "focusObjectChange")
|
||||
class ObjectList extends Component<IMixinStatusProps & IMixinSettingProps> {
|
||||
|
||||
private handelChange = () => {
|
||||
this.forceUpdate();
|
||||
}
|
||||
|
||||
public componentDidMount(){
|
||||
if (this.props.status) {
|
||||
this.props.status.model.on("objectChange", this.handelChange);
|
||||
this.props.status.on("focusObjectChange", this.handelChange);
|
||||
}
|
||||
}
|
||||
|
||||
public componentWillUnmount(){
|
||||
if (this.props.status) {
|
||||
this.props.status.model.off("objectChange", this.handelChange);
|
||||
this.props.status.off("focusObjectChange", this.handelChange);
|
||||
}
|
||||
}
|
||||
|
||||
private renderList() {
|
||||
const objList = this.props.status?.model.objectPool ?? [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user