From 67ece5379241a84df69b306d8f1e7c5736af3a53 Mon Sep 17 00:00:00 2001 From: Azmoria <65363489+Azmoria@users.noreply.github.com> Date: Tue, 10 Oct 2023 10:42:28 -0400 Subject: [PATCH] Beta Fix - undeletable tokens after duplicating a scene. --- ScenesPanel.js | 11 +++++++++++ Token.js | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ScenesPanel.js b/ScenesPanel.js index e2e77682c..115586833 100644 --- a/ScenesPanel.js +++ b/ScenesPanel.js @@ -2097,6 +2097,17 @@ async function duplicate_scene(sceneId) { id: uuid() } + for(token in aboveSceneData.tokens){ + let oldId = aboveSceneData.tokens[token].id; + let newId = uuid(); + for(noteID in window.JOURNAL.notes){ + if(oldId == noteID){ + window.JOURNAL.notes[newId] = {...window.JOURNAL.notes[noteID]}; + } + } + window.JOURNAL.persist(); + aboveSceneData.tokens[token].id = newId; + } await AboveApi.migrateScenes(window.gameId, [aboveSceneData]); diff --git a/Token.js b/Token.js index 322b63b90..1d1b7c498 100644 --- a/Token.js +++ b/Token.js @@ -3568,9 +3568,9 @@ function delete_selected_tokens() { tokensToDelete.forEach(t => window.TOKEN_OBJECTS_RECENTLY_DELETED[t.options.id] = Object.assign({}, t.options)); console.log("delete_selected_tokens", window.TOKEN_OBJECTS_RECENTLY_DELETED); - for (let i = 0; i < tokensToDelete.length; i++) { - tokensToDelete[i].delete(true); - } + for (let i = 0; i < tokensToDelete.length; i++) { + tokensToDelete[i].delete(true); + } draw_selected_token_bounding_box(); // redraw the selection box }