From 99cda9f344ae74e51040de96a4c4cd4534f1cd36 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sun, 10 Apr 2022 18:56:32 -0500 Subject: [PATCH] Fixed attempting to delete persistent ref when there's no layer being added --- src/game/persistence.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/game/persistence.ts b/src/game/persistence.ts index 021298c..ab1bc3b 100644 --- a/src/game/persistence.ts +++ b/src/game/persistence.ts @@ -65,8 +65,9 @@ export function persistent(defaultValue: T | Ref): Persisten export function deletePersistent(persistent: Persistent) { if (addingLayers.length === 0) { console.warn("Deleting a persistent ref outside of a layer. Ignoring...", persistent); + } else { + persistentRefs[addingLayers[addingLayers.length - 1]].delete(persistent); } - persistentRefs[addingLayers[addingLayers.length - 1]].delete(persistent); persistent[Deleted] = true; } @@ -89,7 +90,8 @@ globalBus.on("addLayer", (layer: GenericLayer, saveData: Record } persistentRefs[layer.id].delete( ProxyState in value - ? ((value as any)[ProxyState] as Persistent) + ? // eslint-disable-next-line @typescript-eslint/no-explicit-any + ((value as any)[ProxyState] as Persistent) : (value as Persistent) );