fix: composable used outside ... issue + disable cache (#3947)

This commit is contained in:
IMB11 2025-07-08 21:09:36 +01:00 committed by GitHub
parent 6caf794ae1
commit 26df6f51ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -719,7 +719,9 @@ async function fetchCapacityStatuses(customProduct = null) {
product.metadata.ram < min.metadata.ram ? product : min,
),
];
const capacityChecks = productsToCheck.map((product) =>
const capacityChecks = [];
for (const product of productsToCheck) {
capacityChecks.push(
useServersFetch("stock", {
method: "POST",
body: {
@ -731,19 +733,18 @@ async function fetchCapacityStatuses(customProduct = null) {
bypassAuth: true,
}),
);
const results = await Promise.all(capacityChecks);
}
if (customProduct?.metadata) {
return {
custom: results[0],
custom: await capacityChecks[0],
};
} else {
return {
small: results[0],
medium: results[1],
large: results[2],
custom: results[3],
small: await capacityChecks[0],
medium: await capacityChecks[1],
large: await capacityChecks[2],
custom: await capacityChecks[3],
};
}
} catch (error) {
@ -760,6 +761,11 @@ async function fetchCapacityStatuses(customProduct = null) {
const { data: capacityStatuses, refresh: refreshCapacity } = await useAsyncData(
"ServerCapacityAll",
fetchCapacityStatuses,
{
getCachedData() {
return null; // Dont cache stock data.
},
},
);
const isSmallAtCapacity = computed(() => capacityStatuses.value?.small?.available === 0);