diff --git a/devNotes/twine JS b/devNotes/twine JS index fc97687892d68f75ac4816589bb024a314e96876..bbe5727bd65e3a275dfcc86c67452a4c12f530ae 100644 --- a/devNotes/twine JS +++ b/devNotes/twine JS @@ -6872,13 +6872,9 @@ window.addSlave = function addSlave(slave) { }; window.removeSlave = function removeSlave(index) { - delete State.variables.slaveIndices[State.variables.slaves[index].ID]; - for (var key in State.variables.slaveIndices) { - if (State.variables.slaveIndices[key] > index) { - State.variables.slaveIndices[key] -= 1; - } - } - return State.variables.slaves.deleteAt(index); + const ret = State.variables.slaves.deleteAt(index); + State.variables.slaveIndices = slaves2indices(); + return ret; }; window.slaves2indices = function slaves2indices() { @@ -9258,4 +9254,4 @@ window.setColors = function(colorMap){ } }); }); -} \ No newline at end of file +} diff --git a/src/js/assayJS.tw b/src/js/assayJS.tw index 797f19d48addd7f94c8165a039e5fd802bbd2f17..2cc8bafdf470ff624fe1cada4061672cc32d5872 100644 --- a/src/js/assayJS.tw +++ b/src/js/assayJS.tw @@ -221,13 +221,9 @@ window.addSlave = function addSlave(slave) { }; window.removeSlave = function removeSlave(index) { - delete State.variables.slaveIndices[State.variables.slaves[index].ID]; - for (var key in State.variables.slaveIndices) { - if (State.variables.slaveIndices[key] > index) { - State.variables.slaveIndices[key] -= 1; - } - } - return State.variables.slaves.deleteAt(index); + const ret = State.variables.slaves.deleteAt(index); + State.variables.slaveIndices = slaves2indices(); + return ret; }; window.slaves2indices = function slaves2indices() {