From faf69e8ddf268f432f9e15d11f4308748a47d228 Mon Sep 17 00:00:00 2001
From: DCoded <dicoded@email.com>
Date: Mon, 28 Jun 2021 23:04:36 -0400
Subject: [PATCH] Fixed custom nodes not refreshing correctly

---
 src/004-base/facilityFramework.js   | 24 +++++++++++++++++-------
 src/facilities/farmyard/farmyard.js | 16 ++++++++--------
 2 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/src/004-base/facilityFramework.js b/src/004-base/facilityFramework.js
index 4dcd80f86d1..9546dec278a 100644
--- a/src/004-base/facilityFramework.js
+++ b/src/004-base/facilityFramework.js
@@ -33,14 +33,8 @@ App.Facilities.Facility = class {
 			() => this._expand(expandArgs),
 			() => this._makeUpgrades(),
 			() => this._makeRules(),
+			() => this._makeCustomNodes(),
 			() => this._menials(),
-		);
-
-		if (this.customNodes.length > 0) {
-			this.customNodes.forEach(node => this._addSections(() => node));
-		}
-
-		this._addSections(
 			() => this._stats(),
 			() => this._slaves(),
 			() => this._rename(),
@@ -257,6 +251,22 @@ App.Facilities.Facility = class {
 		return div;
 	}
 
+	/**
+	 * Creates any custom nodes and adds them to the facility.
+	 *
+	 * @private
+	 * @returns {HTMLDivElement}
+	 */
+	_makeCustomNodes() {
+		const div = document.createElement("div");
+
+		if (this.customNodes.length > 0) {
+			this.customNodes.forEach(node => div.append(node));
+		}
+
+		return div;
+	}
+
 	/**
 	 * Allows menial slaves to be bought, sold, and assigned to the facility.
 	 *
diff --git a/src/facilities/farmyard/farmyard.js b/src/facilities/farmyard/farmyard.js
index 19d51ee2a32..76b1fe374ba 100644
--- a/src/facilities/farmyard/farmyard.js
+++ b/src/facilities/farmyard/farmyard.js
@@ -434,8 +434,8 @@ App.Facilities.Farmyard.farmyard = class extends App.Facilities.Facility {
 				V.farmyardKennels = 1;
 				V.PC.skill.engineering += .1;
 
-				this.refresh();	// FIXME: this isn't working for some reason
-			}, [], passage(), `Costs ${cashFormat(cost)}, will incur upkeep costs, and unlocks domestic canines.`), ['indent']);
+				this.refresh();
+			}, [], '', `Costs ${cashFormat(cost)}, will incur upkeep costs, and unlocks domestic canines.`), ['indent']);
 		} else if (V.farmyardKennels === 1) {
 			div.append(App.UI.DOM.passageLink("Kennels", "Farmyard Animals"), ` have been built in one corner of ${V.farmyardName}, and are currently ${CL < 1 ? `empty` : `occupied by ${dogs}`}.`);
 
@@ -446,7 +446,7 @@ App.Facilities.Farmyard.farmyard = class extends App.Facilities.Facility {
 					V.PC.skill.engineering += .1;
 
 					this.refresh();
-				}, [], passage(), `Costs ${cashFormat(cost * 2)} will incur additional upkeep costs, and unlocks exotic canines.`), ['indent']);
+				}, [], '', `Costs ${cashFormat(cost * 2)} will incur additional upkeep costs, and unlocks exotic canines.`), ['indent']);
 			} else {
 				App.UI.DOM.appendNewElement("div", div, App.UI.DOM.disabledLink("Upgrade kennels",
 					[`You must be more reputable to be able to house exotic canines.`]),
@@ -480,7 +480,7 @@ App.Facilities.Farmyard.farmyard = class extends App.Facilities.Facility {
 				V.PC.skill.engineering += .1;
 
 				this.refresh();
-			}, [], passage(), `Costs ${cashFormat(cost)}, will incur upkeep costs, and unlocks domestic hooved animals.`), ['indent']);
+			}, [], '', `Costs ${cashFormat(cost)}, will incur upkeep costs, and unlocks domestic hooved animals.`), ['indent']);
 		} else if (V.farmyardStables === 1) {
 			div.append(App.UI.DOM.passageLink("Stables", "Farmyard Animals"), ` have been built in one corner of ${V.farmyardName}, and are currently ${HL < 1 ? `empty` : `occupied by ${hooved}`}.`);
 
@@ -491,7 +491,7 @@ App.Facilities.Farmyard.farmyard = class extends App.Facilities.Facility {
 					V.PC.skill.engineering += .1;
 
 					this.refresh();
-				}, [], passage(), `Costs ${cashFormat(cost * 2)}, will incur additional upkeep costs, and unlocks exotic hooved animals.`), ['indent']);
+				}, [], '', `Costs ${cashFormat(cost * 2)}, will incur additional upkeep costs, and unlocks exotic hooved animals.`), ['indent']);
 			} else {
 				App.UI.DOM.appendNewElement("div", div, App.UI.DOM.disabledLink("Upgrade stables",
 					[`You must be more reputable to be able to house exotic hooved animals.`]),
@@ -535,7 +535,7 @@ App.Facilities.Farmyard.farmyard = class extends App.Facilities.Facility {
 				V.PC.skill.engineering += .1;
 
 				this.refresh();
-			}, [], passage(), `Costs ${cashFormat(cost)}, will incur upkeep costs, and unlocks domestic felines.`), ['indent']);
+			}, [], '', `Costs ${cashFormat(cost)}, will incur upkeep costs, and unlocks domestic felines.`), ['indent']);
 		} else if (V.farmyardCages === 1) {
 			div.append(App.UI.DOM.passageLink("Cages", "Farmyard Animals"), ` have been built in one corner of ${V.farmyardName}, and are currently ${FL < 1 ? `empty` : `occupied by ${cats}`}.`);
 
@@ -546,7 +546,7 @@ App.Facilities.Farmyard.farmyard = class extends App.Facilities.Facility {
 					V.PC.skill.engineering += .1;
 
 					this.refresh();
-				}, [], passage(), `Costs ${cashFormat(cost * 2)}, will increase upkeep costs, and unlocks exotic felines.`), ['indent']);
+				}, [], '', `Costs ${cashFormat(cost * 2)}, will increase upkeep costs, and unlocks exotic felines.`), ['indent']);
 			} else {
 				App.UI.DOM.appendNewElement("div", div, App.UI.DOM.disabledLink("Upgrade cages",
 					[`You must be more reputable to be able to house exotic felines.`]),
@@ -579,7 +579,7 @@ App.Facilities.Farmyard.farmyard = class extends App.Facilities.Facility {
 
 				this.refresh();
 			},
-			[], passage(), `Will cost ${cashFormat(cost)}.`), ['indent']);
+			[], '', `Will cost ${cashFormat(cost)}.`), ['indent']);
 		}
 
 		return div;
-- 
GitLab