From 5de451e8e0cec8716f9597766c12cb461953145e Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 19 Jun 2018 14:52:49 +1200 Subject: [PATCH] Update entity list upon entity deletion --- scripts/system/edit.js | 22 +++++++++++++--------- scripts/system/html/js/entityList.js | 2 +- scripts/system/html/js/entityProperties.js | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 02af474f55..01e4a071e1 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -475,18 +475,22 @@ var toolBar = (function () { var DELETE_ENTITY_TIMER_TIMEOUT = 100; function checkDeletedEntityAndUpdate(entityID) { + // Allow for multiple entity deletes before updating the entities selected. if (selectionManager.selections.indexOf(entityID) !== -1) { - // Allow for multiple entity deletes before updating the entities selected. entitiesToDelete.push(entityID); - if (deletedEntityTimer !== null) { - Script.clearTimeout(deletedEntityTimer); - } - deletedEntityTimer = Script.setTimeout(function () { - selectionManager.removeEntities(entitiesToDelete); - entitiesToDelete = []; - deletedEntityTimer = null; - }, DELETE_ENTITY_TIMER_TIMEOUT); } + if (deletedEntityTimer !== null) { + Script.clearTimeout(deletedEntityTimer); + } + deletedEntityTimer = Script.setTimeout(function () { + if (entitiesToDelete.length > 0) { + selectionManager.removeEntities(entitiesToDelete); + } + entityListTool.clearEntityList(); + entityListTool.sendUpdate(); + entitiesToDelete = []; + deletedEntityTimer = null; + }, DELETE_ENTITY_TIMER_TIMEOUT); } function initialize() { diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 88b3ccbf7c..0b02dd6d4f 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -346,7 +346,7 @@ function loaded() { if (notFound) { refreshEntities(); } - } else if (data.type == "update") { + } else if (data.type == "update" && data.selectedIDs !== undefined) { var newEntities = data.entities; if (newEntities && newEntities.length == 0) { elNoEntitiesMessage.style.display = "block"; diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 4271aa9b09..f5b24a5f8e 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -893,9 +893,9 @@ function loaded() { } else { elServerScriptStatus.innerText = "Not running"; } - } else if (data.type === "update") { + } else if (data.type === "update" && data.selections) { - if (!data.selections || data.selections.length === 0) { + if (data.selections.length === 0) { if (lastEntityID !== null) { if (editor !== null) { saveJSONUserData(true);