From 304f7e25fb2a533876a59bca7215126d02d94dbf Mon Sep 17 00:00:00 2001
From: alinayejin <alina_kim@brown.edu>
Date: Tue, 5 Dec 2023 13:34:04 -0500
Subject: new collection freeform info ui

---
 .../views/collections/collectionFreeForm/CollectionFreeFormView.tsx  | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx')

diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index cf07d070d..499e0d284 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -51,6 +51,7 @@ import { CollectionFreeFormRemoteCursors } from './CollectionFreeFormRemoteCurso
 import './CollectionFreeFormView.scss';
 import { MarqueeView } from './MarqueeView';
 import React = require('react');
+import { CollectionFreeFormInfoUI } from './CollectionFreeFormInfoUI';
 
 export type collectionFreeformViewProps = {
     NativeWidth?: () => number;
@@ -1429,6 +1430,10 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
         return anchor;
     };
 
+    infoUI = () => {
+        return <CollectionFreeFormInfoUI Document={this.Document} Freeform={this}></CollectionFreeFormInfoUI>;
+    }; // this.props.PanelWidth(), this.props.PanelHeight()
+
     componentDidMount() {
         this.props.setContentView?.(this);
         super.componentDidMount?.();
-- 
cgit v1.2.3-70-g09d2


From df4c0931b6596d7b43a091f7ab5474d47c4f4ab4 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Wed, 6 Dec 2023 22:54:43 -0500
Subject: cleanup

---
 .../CollectionFreeFormInfoState.tsx                  | 20 ++++++++++----------
 .../collectionFreeForm/CollectionFreeFormInfoUI.tsx  |  4 ++--
 .../collectionFreeForm/CollectionFreeFormView.tsx    |  4 +---
 3 files changed, 13 insertions(+), 15 deletions(-)

(limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx')

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);
-- 
cgit v1.2.3-70-g09d2

