From 63836327aee8571cf288f237f3dc4ec5ee6c7c0f Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Fri, 22 May 2020 21:01:36 -0700
Subject: [PATCH] Slave lists now run by ID, not by index.

---
 src/js/findSlave.js | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/js/findSlave.js b/src/js/findSlave.js
index ca370f9fb0f..55dec43bce4 100644
--- a/src/js/findSlave.js
+++ b/src/js/findSlave.js
@@ -16,10 +16,10 @@ App.FindSlave._fragmentSearch = function(haystacks, needles) {
  * @param {function(App.Entity.SlaveState): boolean} predicate
  * @returns {number[]}
  */
-App.FindSlave._slaveIndices = function(predicate) {
-	return V.slaves.reduce((acc, slave, ind) => {
+App.FindSlave._slaveIDs = function(predicate) {
+	return V.slaves.reduce((acc, slave) => {
 		if (predicate(createReadonlyProxy(slave))) {
-			acc.push(ind);
+			acc.push(slave.ID);
 		}
 		return acc;
 	}, []);
@@ -32,8 +32,8 @@ App.FindSlave._slaveIndices = function(predicate) {
  */
 App.FindSlave.searchByName = function(query) {
 	const needles = query.split(" ").map((needle) => { return new RegExp(needle, "i"); });
-	const indices = this._slaveIndices((slave) => { return this._fragmentSearch([slave.slaveName, slave.slaveSurname, slave.birthName, slave.birthSurname], needles); });
-	return App.UI.SlaveList.render.listDOM(indices, [], App.UI.SlaveList.SlaveInteract.stdInteract);
+	const ids = this._slaveIDs((slave) => { return this._fragmentSearch([slave.slaveName, slave.slaveSurname, slave.birthName, slave.birthSurname], needles); });
+	return App.UI.SlaveList.render.listDOM(ids, [], App.UI.SlaveList.SlaveInteract.stdInteract);
 };
 
 /**
@@ -43,8 +43,8 @@ App.FindSlave.searchByName = function(query) {
  */
 App.FindSlave.searchByBackground = function(query) {
 	const needles = query.split(" ").map((needle) => { return new RegExp(needle, "i"); });
-	const indices = this._slaveIndices((slave) => { return this._fragmentSearch([slave.career, slave.origin], needles); });
-	return App.UI.SlaveList.render.listDOM(indices, [], App.UI.SlaveList.SlaveInteract.stdInteract);
+	const ids = this._slaveIDs((slave) => { return this._fragmentSearch([slave.career, slave.origin], needles); });
+	return App.UI.SlaveList.render.listDOM(ids, [], App.UI.SlaveList.SlaveInteract.stdInteract);
 };
 
 /**
@@ -54,6 +54,6 @@ App.FindSlave.searchByBackground = function(query) {
  */
 App.FindSlave.searchByExpression = function(query) {
 	const pred = new Function("slave", "return (" + query + ");");
-	const indices = runWithReadonlyProxy(() => { return this._slaveIndices(pred); });
-	return App.UI.SlaveList.render.listDOM(indices, [], App.UI.SlaveList.SlaveInteract.stdInteract);
+	const ids = runWithReadonlyProxy(() => { return this._slaveIDs(pred); });
+	return App.UI.SlaveList.render.listDOM(ids, [], App.UI.SlaveList.SlaveInteract.stdInteract);
 };
-- 
GitLab