From 2a17392bd461bfdc669961c5bf8892b7cb6958d6 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Fri, 12 Mar 2021 17:49:35 -0500
Subject: trying to make treeViews more efficient by making fewer calls to Get
 document fields getter.

---
 src/client/views/collections/CollectionDockingView.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 0c8e26e91..7d07439ce 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -337,7 +337,7 @@ export class CollectionDockingView extends CollectionSubView(doc => doc) {
             }
         }
         if (!e.nativeEvent.cancelBubble && !InteractionUtils.IsType(e, InteractionUtils.TOUCHTYPE) && !InteractionUtils.IsType(e, InteractionUtils.PENTYPE) &&
-            Doc.GetSelectedTool() !== InkTool.Highlighter && Doc.GetSelectedTool() !== InkTool.Pen) {
+            ![InkTool.Highlighter, InkTool.Pen].includes(CurrentUserUtils.SelectedTool)) {
             e.stopPropagation();
         }
     }
-- 
cgit v1.2.3-70-g09d2


From 87792248abadeb4cd1361530bdef2472bfcb5cbf Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Fri, 12 Mar 2021 18:09:46 -0500
Subject: dont add kvp docs to unused tabs

---
 src/client/views/collections/CollectionDockingView.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 7d07439ce..5da75b1b7 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -380,7 +380,7 @@ export class CollectionDockingView extends CollectionSubView(doc => doc) {
             tabs && (Doc.GetProto(tabs).data = new List<Doc>(docs));
             const otherSet = new Set<Doc>();
             otherdocs?.filter(doc => !docs.includes(doc)).forEach(doc => otherSet.add(doc));
-            tabdocs?.filter(doc => !docs.includes(doc)).forEach(doc => otherSet.add(doc));
+            tabdocs?.filter(doc => !docs.includes(doc) && doc.type !== DocumentType.KVP).forEach(doc => otherSet.add(doc));
             other && (Doc.GetProto(other).data = new List<Doc>(Array.from(otherSet.values())));
         }, 0);
     }
-- 
cgit v1.2.3-70-g09d2


From b18d4d2b9a4a624e61116642d4dbfe9a53437d0c Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Fri, 12 Mar 2021 22:18:10 -0500
Subject: prevent anything but Docs from being written to offScreenTabs.  fixed
 tabs to activate an unrendered tab when it is uncovered for the first time.

---
 src/client/views/collections/CollectionDockingView.tsx | 9 +++++----
 src/client/views/collections/TabDocView.tsx            | 8 ++++----
 src/client/views/nodes/KeyValueBox.tsx                 | 9 ++-------
 3 files changed, 11 insertions(+), 15 deletions(-)

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

diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 5da75b1b7..3556e74bc 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -372,16 +372,17 @@ export class CollectionDockingView extends CollectionSubView(doc => doc) {
 
         this.props.Document.dockingConfig = json;
         setTimeout(async () => {
-            const sublists = DocListCast(this.props.Document[this.props.fieldKey]);
-            const tabs = Cast(sublists[0], Doc, null);
-            const other = Cast(sublists[1], Doc, null);
+            const sublists = await DocListCastAsync(this.props.Document[this.props.fieldKey]);
+            const tabs = sublists && Cast(sublists[0], Doc, null);
+            const other = sublists && Cast(sublists[1], Doc, null);
             const tabdocs = await DocListCastAsync(tabs?.data);
             const otherdocs = await DocListCastAsync(other?.data);
             tabs && (Doc.GetProto(tabs).data = new List<Doc>(docs));
             const otherSet = new Set<Doc>();
             otherdocs?.filter(doc => !docs.includes(doc)).forEach(doc => otherSet.add(doc));
             tabdocs?.filter(doc => !docs.includes(doc) && doc.type !== DocumentType.KVP).forEach(doc => otherSet.add(doc));
-            other && (Doc.GetProto(other).data = new List<Doc>(Array.from(otherSet.values())));
+            const vals = Array.from(otherSet.values()).filter(val => val instanceof Doc).map(d => d as Doc).filter(d => d.type !== DocumentType.KVP);
+            other && (Doc.GetProto(other).data = new List<Doc>(vals));
         }, 0);
     }
 
diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx
index e0bbd1224..2ead98aa4 100644
--- a/src/client/views/collections/TabDocView.tsx
+++ b/src/client/views/collections/TabDocView.tsx
@@ -220,7 +220,7 @@ export class TabDocView extends React.Component<TabDocViewProps> {
             }
         })).observe(this.props.glContainer._element[0]);
         this.props.glContainer.layoutManager.on("activeContentItemChanged", this.onActiveContentItemChanged);
-        this.props.glContainer.tab?.isActive && this.onActiveContentItemChanged();
+        this.props.glContainer.tab?.isActive && this.onActiveContentItemChanged(undefined);
         this._tabReaction = reaction(() => ({ selected: this.active(), title: this.tab?.titleElement[0] }),
             ({ selected, title }) => title && (title.style.backgroundColor = selected ? "white" : ""),
             { fireImmediately: true });
@@ -234,9 +234,9 @@ export class TabDocView extends React.Component<TabDocViewProps> {
     }
 
     @action.bound
-    private onActiveContentItemChanged() {
-        if (this.props.glContainer.tab && this._isActive !== this.props.glContainer.tab.isActive) {
-            this._isActive = this.props.glContainer.tab.isActive;
+    private onActiveContentItemChanged(contentItem: any) {
+        if (!contentItem || (this.stack === contentItem.parent && ((contentItem?.tab === this.tab && !this._isActive) || (contentItem?.tab !== this.tab && this._isActive)))) {
+            this._activated = this._isActive = !contentItem || contentItem?.tab === this.tab;
             (CollectionDockingView.Instance as any)._goldenLayout?.isInitialised && CollectionDockingView.Instance.stateChanged();
             !this._isActive && this._document && Doc.UnBrushDoc(this._document); // bcz: bad -- trying to simulate a pointer leave event when a new tab is opened up on top of an existing one.
         }
diff --git a/src/client/views/nodes/KeyValueBox.tsx b/src/client/views/nodes/KeyValueBox.tsx
index 8acf4081c..383650e89 100644
--- a/src/client/views/nodes/KeyValueBox.tsx
+++ b/src/client/views/nodes/KeyValueBox.tsx
@@ -61,10 +61,7 @@ export class KeyValueBox extends React.Component<FieldViewProps> {
         const options: ScriptOptions = { addReturn: true, params: { this: "Doc", _last_: "any" }, editable: false };
         if (dubEq) options.typecheck = false;
         const script = CompileScript(value, options);
-        if (!script.compiled) {
-            return undefined;
-        }
-        return { script, type: dubEq, onDelegate: eq };
+        return !script.compiled ? undefined : { script, type: dubEq, onDelegate: eq };
     }
 
     public static ApplyKVPScript(doc: Doc, key: string, kvpScript: KVPScript, forceOnDelegate?: boolean): boolean {
@@ -100,9 +97,7 @@ export class KeyValueBox extends React.Component<FieldViewProps> {
             e.stopPropagation();
         }
     }
-    onPointerWheel = (e: React.WheelEvent): void => {
-        e.stopPropagation();
-    }
+    onPointerWheel = (e: React.WheelEvent): void => e.stopPropagation();
 
     rowHeight = () => 30;
 
-- 
cgit v1.2.3-70-g09d2

