diff options
author | bobzel <zzzman@gmail.com> | 2023-12-06 22:54:43 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2023-12-06 22:54:43 -0500 |
commit | df4c0931b6596d7b43a091f7ab5474d47c4f4ab4 (patch) | |
tree | 4655c8c7e26df700cdb7975c2580e3d71b24fa13 /src | |
parent | cd9ad39d3a1cafc410c7a04ce6ed44cc926175de (diff) |
cleanup
Diffstat (limited to 'src')
3 files changed, 13 insertions, 15 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx index bf47820a1..baf91da32 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx @@ -23,7 +23,9 @@ export interface CollectionFreeFormInfoStateProps { @observer export class CollectionFreeFormInfoState extends React.Component<CollectionFreeFormInfoStateProps> { _disposers: IReactionDisposer[] = []; - componentDidMount(): void { + + clearState = () => this._disposers.map(disposer => disposer()); + initState = () => { this._disposers = this.props.state.Arcs.map(arc => reaction( () => arc.events(), @@ -31,19 +33,17 @@ export class CollectionFreeFormInfoState extends React.Component<CollectionFreeF { fireImmediately: true } ) ); + }; + + componentDidMount(): void { + this.initState(); } componentWillUpdate() { - this._disposers.map(disposer => disposer()); - this._disposers = this.props.state.Arcs.map(arc => - reaction( - () => arc.events(), - args => arc.actions(args), - { fireImmediately: true } - ) - ); + this.clearState(); + this.initState(); } componentWillUnmount(): void { - this._disposers.map(disposer => disposer()); + this.clearState(); } render() { return <div className="infoUI">{this.props.state.Message}</div>; diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx index 8b2b32581..dfe77482f 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx @@ -65,7 +65,7 @@ export class CollectionFreeFormInfoUI extends React.Component<CollectionFreeForm const { links, docs } = arc; if (docs.length === 0) this.currState = this.state0; if (docs.length === 1) this.currState = this.state1; - if (links.length) this.currState = this.state3; + if (links?.length) this.currState = this.state3; }, }, ], @@ -79,7 +79,7 @@ export class CollectionFreeFormInfoUI extends React.Component<CollectionFreeForm actions: arc => { const { links, viewingLinks } = arc; if (viewingLinks) this.currState = this.state4; - if (links.length === 0) this.currState = this.state2; + if (links?.length === 0) this.currState = this.state2; }, }, ], diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index e432c9682..91617ec44 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -1429,9 +1429,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection return anchor; }; - infoUI = () => { - return <CollectionFreeFormInfoUI Document={this.Document} Freeform={this}></CollectionFreeFormInfoUI>; - }; // this.props.PanelWidth(), this.props.PanelHeight() + infoUI = () => <CollectionFreeFormInfoUI Document={this.Document} Freeform={this} />; componentDidMount() { this.props.setContentView?.(this); |