Update entity list upon entity deletion

This commit is contained in:
David Rowe 2018-06-19 14:52:49 +12:00
parent e8154b5df1
commit 5de451e8e0
3 changed files with 16 additions and 12 deletions

View file

@ -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() {

View file

@ -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";

View file

@ -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);