From 08334824ad07dea1d0bb56d8ef91e3ad1a4573b0 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 25 Apr 2024 18:03:15 -0400
Subject: added toList() for Doc|Doc[]

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

(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 a14dcb592..fa4dbf9a2 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -17,7 +17,7 @@ import { List } from '../../../../fields/List';
 import { RichTextField } from '../../../../fields/RichTextField';
 import { listSpec } from '../../../../fields/Schema';
 import { ScriptField } from '../../../../fields/ScriptField';
-import { BoolCast, Cast, DocCast, NumCast, ScriptCast, StrCast } from '../../../../fields/Types';
+import { BoolCast, Cast, DocCast, NumCast, ScriptCast, StrCast, toList } from '../../../../fields/Types';
 import { ImageField } from '../../../../fields/URLField';
 import { TraceMobx } from '../../../../fields/util';
 import { Gestures, PointData } from '../../../../pen-gestures/GestureTypes';
@@ -284,7 +284,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
             // bcz: deal with clusters
         }
         if (retVal) {
-            const newBoxes = newBox instanceof Doc ? [newBox] : newBox;
+            const newBoxes = toList(newBox);
             newBoxes.forEach(box => {
                 if (box.activeFrame !== undefined) {
                     const vals = CollectionFreeFormDocumentView.animFields.map(field => box[field.key]);
@@ -1281,7 +1281,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
         );
     }
     addDocTab = action((docsIn: Doc | Doc[], where: OpenWhere) => {
-        const docs = docsIn instanceof Doc ? [docsIn] : docsIn;
+        const docs = toList(docsIn);
         if (this._props.isAnnotationOverlay) return this._props.addDocTab(docs, where);
         switch (where) {
             case OpenWhere.inParent:
@@ -1290,7 +1290,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
                 const docContext = DocCast(docs[0]?.embedContainer);
                 return (
                     (this.addDocument?.(
-                        (docs instanceof Doc ? [docs] : docs).map(doc => {
+                        toList(docs).map(doc => {
                             [doc.x, doc.y] = this.screenToFreeformContentsXf.transformPoint(NumCast(doc.x), NumCast(doc.y));
                             return doc;
                         })
-- 
cgit v1.2.3-70-g09d2

