aboutsummaryrefslogtreecommitdiff
path: root/featureClass/featureManager.js
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-09-06 21:39:53 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-09-06 21:39:53 +0800
commit645b351e5a76e20ac16ce8ea80cd1250e93c7aad (patch)
treeef6c31419c4b59efcad884fcb8325f52905ba622 /featureClass/featureManager.js
parent994b25cf01b1cd5fba879908cb8a524add6c2c24 (diff)
downloadSoopyV2-645b351e5a76e20ac16ce8ea80cd1250e93c7aad.tar.gz
SoopyV2-645b351e5a76e20ac16ce8ea80cd1250e93c7aad.tar.bz2
SoopyV2-645b351e5a76e20ac16ce8ea80cd1250e93c7aad.zip
Load all features simultanously to speed up loading
Diffstat (limited to 'featureClass/featureManager.js')
-rw-r--r--featureClass/featureManager.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/featureClass/featureManager.js b/featureClass/featureManager.js
index 75ffa48..4aae70f 100644
--- a/featureClass/featureManager.js
+++ b/featureClass/featureManager.js
@@ -748,18 +748,30 @@ class FeatureManager {
loadSoopy() {
ChatLib.chat(this.messagePrefix + "Loading SoopyV2...")
+ let startLoading = Date.now()
this.loadFeatureMetas()
this.loadFeatureSettings()
+ let loadedFeatures = new Map()
+
Object.keys(this.featureMetas).forEach((feature) => {
if (this.featureSettingsData[feature] && this.featureSettingsData[feature].enabled) {
- this.loadFeature(feature)
+ loadedFeatures.set(feature, false)
+ new Thread(() => {
+ this.loadFeature(feature)
+ loadedFeatures.set(feature, true)
+ }).start()
}
})
+ while ([...loadedFeatures.values()].some(a => !a)) {
+ Thread.sleep(100)
+ }
+
this.finishedLoading = true
ChatLib.chat(this.messagePrefix + "SoopyV2 Loaded!")
+ logger.logMessage("SoopyV2 took " + ((Date.now() - startLoading) / 1000).toFixed(2) + "s to load", 3)
}
loadFeature(feature) { //run in seperate thread so onenable can do network requests