Added catalogue version to make webpages not need to repeatedly fetch

info from API.
This commit is contained in:
sarah committed 2026-08-31 20:01:56 +02:00
1 parent dde47ff5a6
commit ce6dced3ad
6 files changed
+374 -85

No files matched your search

+5 -56
View File
@@ -1,30 +1,7 @@
let MutationSets = {};
let MutationsLoadPromise = null;
let GameContentLoadPromise = null;
async function LoadMutations() {
if (MutationsLoadPromise !== null) {
return MutationsLoadPromise;
}
MutationsLoadPromise =
LoadMutationsFromApi();
try {
return await MutationsLoadPromise;
} catch (Error) {
MutationsLoadPromise = null;
throw Error;
}
}
async function LoadMutationsFromApi() {
async function FetchMutationsFromApi() {
const Response =
await fetch(
ApiUrl + "/Mutations.php",
@@ -34,7 +11,9 @@ async function LoadMutationsFromApi() {
headers: {
"Accept":
"application/json"
}
},
cache: "no-store"
}
);
@@ -67,35 +46,5 @@ async function LoadMutationsFromApi() {
}
MutationSets =
Result.Mutations;
return MutationSets;
}
async function LoadGameContent() {
if (GameContentLoadPromise === null) {
GameContentLoadPromise =
Promise.all([
LoadPlants(),
LoadMutations()
]);
}
try {
await GameContentLoadPromise;
} catch (Error) {
GameContentLoadPromise = null;
throw Error;
}
return {
Plants: Plants,
Mutations: MutationSets
};
return Result.Mutations;
}