From 3f51ab416090a249aab489b3eb21a456b4d42143 Mon Sep 17 00:00:00 2001 From: bobzel Date: Sun, 27 Aug 2023 21:44:25 -0400 Subject: fixed exceptions when delete entities from a Map when it's in the process of unmounting --- src/client/views/nodes/MapBox/MapBox.tsx | 15 ++++++++++++--- src/client/views/nodes/MapBox/MapPushpinBox.tsx | 1 - 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/MapBox/MapBox.tsx b/src/client/views/nodes/MapBox/MapBox.tsx index 6f552953d..f0106dbbb 100644 --- a/src/client/views/nodes/MapBox/MapBox.tsx +++ b/src/client/views/nodes/MapBox/MapBox.tsx @@ -98,10 +98,13 @@ export class MapBox extends ViewBoxAnnotatableComponent this._disposers[key]?.()); } @@ -343,10 +346,14 @@ export class MapBox extends ViewBoxAnnotatableComponent this.pushpinClicked(temp as Doc)); - this._bingMap.current.entities.push(newpin); + if (!this._unmounting) { + this._bingMap.current.entities.push(newpin); + } this.map_docToPinMap.set(temp, newpin); this.selectedPin = undefined; this.bingSearchBarContents = this.rootDoc.map; @@ -488,7 +495,9 @@ export class MapBox extends ViewBoxAnnotatableComponent { - this._bingMap.current.entities.remove(this.map_docToPinMap.get(pinDoc)); + if (!this._unmounting) { + this._bingMap.current.entities.remove(this.map_docToPinMap.get(pinDoc)); + } this.map_docToPinMap.delete(pinDoc); this.selectedPin = undefined; }; diff --git a/src/client/views/nodes/MapBox/MapPushpinBox.tsx b/src/client/views/nodes/MapBox/MapPushpinBox.tsx index 552bceace..42bada0ef 100644 --- a/src/client/views/nodes/MapBox/MapPushpinBox.tsx +++ b/src/client/views/nodes/MapBox/MapPushpinBox.tsx @@ -15,7 +15,6 @@ export class MapPushpinBox extends ViewBoxBaseComponent() { return FieldView.LayoutString(MapPushpinBox, fieldKey); } componentDidMount() { - // if (this.mapBoxView) this.mapBoxView.addPushpin(this.rootDoc); } componentWillUnmount() { -- cgit v1.2.3-70-g09d2