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[]

---
 src/client/views/nodes/MapboxMapBox/MapboxContainer.tsx | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'src/client/views/nodes/MapboxMapBox/MapboxContainer.tsx')

diff --git a/src/client/views/nodes/MapboxMapBox/MapboxContainer.tsx b/src/client/views/nodes/MapboxMapBox/MapboxContainer.tsx
index fce52ef4b..67872efc3 100644
--- a/src/client/views/nodes/MapboxMapBox/MapboxContainer.tsx
+++ b/src/client/views/nodes/MapboxMapBox/MapboxContainer.tsx
@@ -9,7 +9,7 @@ import { emptyFunction } from '../../../../Utils';
 import { Doc, DocListCast, Field, LinkedTo, Opt } from '../../../../fields/Doc';
 import { DocCss, Highlight } from '../../../../fields/DocSymbols';
 import { Id } from '../../../../fields/FieldSymbols';
-import { DocCast, NumCast, StrCast } from '../../../../fields/Types';
+import { DocCast, NumCast, StrCast, toList } from '../../../../fields/Types';
 import { DocumentType } from '../../../documents/DocumentTypes';
 import { DocUtils, Docs } from '../../../documents/Documents';
 import { DocumentManager } from '../../../util/DocumentManager';
@@ -120,7 +120,7 @@ export class MapBoxContainer extends ViewBoxAnnotatableComponent<FieldViewProps>
      */
     sidebarAddDocument = (docsIn: Doc | Doc[], sidebarKey?: string) => {
         if (!this.layoutDoc._layout_showSidebar) this.toggleSidebar();
-        const docs = docsIn instanceof Doc ? [docsIn] : docsIn;
+        const docs = toList(docsIn);
         docs.forEach(doc => {
             let existingPin = this.allPushpins.find(pin => pin.latitude === doc.latitude && pin.longitude === doc.longitude) ?? this.selectedPin;
             if (doc.latitude !== undefined && doc.longitude !== undefined && !existingPin) {
@@ -142,14 +142,14 @@ export class MapBoxContainer extends ViewBoxAnnotatableComponent<FieldViewProps>
         return this.addDocument(docs, sidebarKey); // add to sidebar list
     };
 
-    removeMapDocument = (doc: Doc | Doc[], annotationKey?: string) => {
-        const docs = doc instanceof Doc ? [doc] : doc;
+    removeMapDocument = (docsIn: Doc | Doc[], annotationKey?: string) => {
+        const docs = toList(docsIn);
         this.allAnnotations
             .filter(anno => docs.includes(DocCast(anno.mapPin)))
             .forEach(anno => {
                 anno.mapPin = undefined;
             });
-        return this.removeDocument(doc, annotationKey, undefined);
+        return this.removeDocument(docsIn, annotationKey, undefined);
     };
 
     /**
-- 
cgit v1.2.3-70-g09d2

