From 2f44d22abec7400be9c93f33b5e4f071fd0aa08a Mon Sep 17 00:00:00 2001 From: Miguel Peres Date: Fri, 18 Mar 2022 17:30:22 -0300 Subject: [PATCH] SD-1774 --- Esper_Genesis_5E/EG_Sheet.html | 17 ++++++++++++++++- Esper_Genesis_5E/sheetworkers.js | 1 + Esper_Genesis_5E/src/dragndrop/DragAndDrop.js | 17 +++++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Esper_Genesis_5E/EG_Sheet.html b/Esper_Genesis_5E/EG_Sheet.html index c9f28ca621..65d48549bf 100644 --- a/Esper_Genesis_5E/EG_Sheet.html +++ b/Esper_Genesis_5E/EG_Sheet.html @@ -6963,7 +6963,21 @@ const dropHelpers = { var lastDropID = ''; var handle_drop = function(category, eventinfo) { getAttrs(["speed", "hp_max", "hp", "drop_name", "drop_data", "drop_content", "character_id", "npc_legendary_actions", "strength_mod", "dexterity_mod", "npc", "base_level", "strength_base", "dexterity_base", "constitution_base", "wisdom_base", "intelligence_base", "charisma_base", "class_resource_name", "other_resource_name", "multiclass1_lvl", "multiclass2_lvl", "multiclass3_lvl"], function(v) { - if((v['drop_name'] && v['drop_name'] == lastDropID) || (v['character_id'] && v['character_id'] == lastDropID)) return; + setAttrs({ + drop_category: "", + drop_name: "", + drop_data: "", + drop_content: "", + }, {silent: true}); + if((v['drop_name'] && v['drop_name'] == lastDropID) || (v['character_id'] && v['character_id'] == lastDropID)) { + lastDropID = ""; + return; + } else { + setTimeout(() => { + console.log("cleaning last ID"); + lastDropID = ""; + }, 2000); + }; if(v['drop_name']) { lastDropID = v['drop_name']; } else if(v['character_id']) { @@ -15102,6 +15116,7 @@ const globalAttributesByCategory = { }; on("sheet:opened", function(eventinfo) { + lastDropID = ""; versioning(function() { var getInfo = function(sections, callback, results) { results = results || {}; diff --git a/Esper_Genesis_5E/sheetworkers.js b/Esper_Genesis_5E/sheetworkers.js index 4a84a8c1be..b44ad9d450 100644 --- a/Esper_Genesis_5E/sheetworkers.js +++ b/Esper_Genesis_5E/sheetworkers.js @@ -56,6 +56,7 @@ const globalAttributesByCategory = { }; on("sheet:opened", function(eventinfo) { + lastDropID = ""; versioning(function() { var getInfo = function(sections, callback, results) { results = results || {}; diff --git a/Esper_Genesis_5E/src/dragndrop/DragAndDrop.js b/Esper_Genesis_5E/src/dragndrop/DragAndDrop.js index 73c64ffd4e..7f6655214d 100644 --- a/Esper_Genesis_5E/src/dragndrop/DragAndDrop.js +++ b/Esper_Genesis_5E/src/dragndrop/DragAndDrop.js @@ -19,7 +19,21 @@ on("change:drop_category", function(eventinfo) { var lastDropID = ''; var handle_drop = function(category, eventinfo) { getAttrs(["speed", "hp_max", "hp", "drop_name", "drop_data", "drop_content", "character_id", "npc_legendary_actions", "strength_mod", "dexterity_mod", "npc", "base_level", "strength_base", "dexterity_base", "constitution_base", "wisdom_base", "intelligence_base", "charisma_base", "class_resource_name", "other_resource_name", "multiclass1_lvl", "multiclass2_lvl", "multiclass3_lvl"], function(v) { - if((v['drop_name'] && v['drop_name'] == lastDropID) || (v['character_id'] && v['character_id'] == lastDropID)) return; + setAttrs({ + drop_category: "", + drop_name: "", + drop_data: "", + drop_content: "", + }, {silent: true}); + if((v['drop_name'] && v['drop_name'] == lastDropID) || (v['character_id'] && v['character_id'] == lastDropID)) { + lastDropID = ""; + return; + } else { + setTimeout(() => { + console.log("cleaning last ID"); + lastDropID = ""; + }, 2000); + }; if(v['drop_name']) { lastDropID = v['drop_name']; } else if(v['character_id']) { @@ -45,7 +59,6 @@ var handle_drop = function(category, eventinfo) { }); }); - }; var processDrop = function(page, currentData, repeating, looped) {