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 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

(limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.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>;
-- 
cgit v1.2.3-70-g09d2


From 6b87d29d668f290f53ca5109b9922663302e0eb2 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Wed, 6 Dec 2023 22:57:16 -0500
Subject: from last

---
 .../collectionFreeForm/CollectionFreeFormInfoState.tsx         | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

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

diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx
index baf91da32..55750a283 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx
@@ -25,15 +25,7 @@ export class CollectionFreeFormInfoState extends React.Component<CollectionFreeF
     _disposers: IReactionDisposer[] = [];
 
     clearState = () => this._disposers.map(disposer => disposer());
-    initState = () => {
-        this._disposers = this.props.state.Arcs.map(arc =>
-            reaction(
-                () => arc.events(),
-                args => arc.actions(args),
-                { fireImmediately: true }
-            )
-        );
-    };
+    initState = () => (this._disposers = this.props.state.Arcs.map(arc => reaction(arc.events, arc.actions, { fireImmediately: true })));
 
     componentDidMount(): void {
         this.initState();
-- 
cgit v1.2.3-70-g09d2


From 8b100971135c0edaa6623bf0c8529ea4e0b8f5bf Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Wed, 6 Dec 2023 23:02:15 -0500
Subject: final cleanup of infoStates for now.

---
 .../collectionFreeForm/CollectionFreeFormInfoState.tsx       | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

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

diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx
index 55750a283..9090d0ea5 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx
@@ -7,14 +7,10 @@ export type infoArc = {
     events: () => any;
     actions: (arg?: any) => any;
 };
-export class infoState {
-    Message: string = '';
-    Arcs: infoArc[] = [];
-    constructor(message: string, arcs: infoArc[]) {
-        this.Message = message;
-        this.Arcs = arcs;
-    }
-}
+export type infoState = {
+    Message: string;
+    Arcs: infoArc[];
+};
 
 export interface CollectionFreeFormInfoStateProps {
     state: infoState;
-- 
cgit v1.2.3-70-g09d2


From 7548211c816af70f6c5dfe92897f82527de3986d Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Wed, 6 Dec 2023 23:28:38 -0500
Subject: final simplification of info ui fsa structure

---
 .../CollectionFreeFormInfoState.tsx                | 13 ++--
 .../CollectionFreeFormInfoUI.tsx                   | 77 ++++++++--------------
 2 files changed, 34 insertions(+), 56 deletions(-)

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

diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx
index 9090d0ea5..3c19ef4e9 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx
@@ -3,13 +3,10 @@ import { observer } from 'mobx-react';
 import './CollectionFreeFormView.scss';
 import React = require('react');
 
-export type infoArc = {
-    events: () => any;
-    actions: (arg?: any) => any;
-};
 export type infoState = {
     Message: string;
-    Arcs: infoArc[];
+    Events: () => any;
+    Actions: (arg?: any) => any;
 };
 
 export interface CollectionFreeFormInfoStateProps {
@@ -18,10 +15,10 @@ export interface CollectionFreeFormInfoStateProps {
 
 @observer
 export class CollectionFreeFormInfoState extends React.Component<CollectionFreeFormInfoStateProps> {
-    _disposers: IReactionDisposer[] = [];
+    _disposer: IReactionDisposer | undefined;
 
-    clearState = () => this._disposers.map(disposer => disposer());
-    initState = () => (this._disposers = this.props.state.Arcs.map(arc => reaction(arc.events, arc.actions, { fireImmediately: true })));
+    clearState = () => this._disposer?.();
+    initState = () => (this._disposer = reaction(this.props.state.Events, this.props.state.Actions, { fireImmediately: true }));
 
     componentDidMount(): void {
         this.initState();
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx
index dfe77482f..74b5545bd 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx
@@ -25,73 +25,54 @@ export class CollectionFreeFormInfoUI extends React.Component<CollectionFreeForm
 
     constructor(props: any) {
         super(props);
-        this.currState = this.state0;
+        this.currState = this.start;
     }
 
+    @observable currState: infoState;
+
     @computed get first_doc() {
         return this.props.Freeform.childDocs.lastElement();
     }
-    @observable currState: infoState;
-    state0: infoState = {
+    start: infoState = {
         Message: 'Click to create Object',
-        Arcs: [
-            {
-                events: () => this.props.Freeform.childDocs.slice(),
-                actions: (docs: Doc[]) => {
-                    if (docs.length === 1) this.currState = this.state1;
-                    if (docs.length > 1) this.currState = this.state2;
-                },
-            },
-        ],
+        Events: () => this.props.Freeform.childDocs,
+        Actions: (docs: Doc[]) => {
+            if (docs.length === 1) this.currState = this.state1;
+            if (docs.length > 1) this.currState = this.state2;
+        },
     };
     state1: infoState = {
         Message: 'Create a second doc',
-        Arcs: [
-            {
-                events: () => this.props.Freeform.childDocs.slice(),
-                actions: (docs: Doc[]) => {
-                    if (docs.length === 0) this.currState = this.state0;
-                    if (docs.length === 2) this.currState = this.state2;
-                },
-            },
-        ],
+        Events: () => this.props.Freeform.childDocs,
+        Actions: (docs: Doc[]) => {
+            if (docs.length === 0) this.currState = this.start;
+            if (docs.length === 2) this.currState = this.state2;
+        },
     };
     state2: infoState = {
         Message: 'Create a link',
-        Arcs: [
-            {
-                events: () => ({ links: this.first_doc && LinkManager.Instance.getAllDirectLinks(this.first_doc), docs: this.props.Freeform.childDocs.slice() }),
-                actions: arc => {
-                    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;
-                },
-            },
-        ],
+        Events: () => ({ links: this.first_doc && LinkManager.Instance.getAllDirectLinks(this.first_doc), docs: this.props.Freeform.childDocs.slice() }),
+        Actions: arc => {
+            const { links, docs } = arc;
+            if (docs.length === 0) this.currState = this.start;
+            if (docs.length === 1) this.currState = this.state1;
+            if (links?.length) this.currState = this.state3;
+        },
     };
 
     state3: infoState = {
         Message: 'View links',
-        Arcs: [
-            {
-                events: () => ({ links: this.first_doc && LinkManager.Instance.getAllDirectLinks(this.first_doc), viewingLinks: DocumentLinksButton.LinkEditorDocView }),
-                actions: arc => {
-                    const { links, viewingLinks } = arc;
-                    if (viewingLinks) this.currState = this.state4;
-                    if (links?.length === 0) this.currState = this.state2;
-                },
-            },
-        ],
+        Events: () => ({ links: this.first_doc && LinkManager.Instance.getAllDirectLinks(this.first_doc), viewingLinks: DocumentLinksButton.LinkEditorDocView }),
+        Actions: arc => {
+            const { links, viewingLinks } = arc;
+            if (viewingLinks) this.currState = this.state4;
+            if (links?.length === 0) this.currState = this.state2;
+        },
     };
     state4: infoState = {
         Message: 'You did it!',
-        Arcs: [
-            {
-                events: () => false,
-                actions: arc => {},
-            },
-        ],
+        Events: () => false,
+        Actions: arc => {},
     };
 
     /*
-- 
cgit v1.2.3-70-g09d2

