From a8921c0c08ba4e6598e739bd6ae4ba16121553a2 Mon Sep 17 00:00:00 2001
From: Vasileios Pasialiokis <whiterocket@outlook.com>
Date: Sun, 15 Apr 2018 21:19:14 +0300
Subject: [PATCH] slightly cleaner slaves2indices

---
 src/js/assayJS.tw | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/js/assayJS.tw b/src/js/assayJS.tw
index 797f19d48ad..2cc8bafdf47 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() {
-- 
GitLab