From 26df6f51efd4168428876475f8c5ced64c7cdc25 Mon Sep 17 00:00:00 2001 From: IMB11 Date: Tue, 8 Jul 2025 21:09:36 +0100 Subject: [PATCH] fix: composable used outside ... issue + disable cache (#3947) --- apps/frontend/src/pages/servers/index.vue | 44 +++++++++++++---------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/apps/frontend/src/pages/servers/index.vue b/apps/frontend/src/pages/servers/index.vue index 9b3c363a8..60495d150 100644 --- a/apps/frontend/src/pages/servers/index.vue +++ b/apps/frontend/src/pages/servers/index.vue @@ -719,31 +719,32 @@ async function fetchCapacityStatuses(customProduct = null) { product.metadata.ram < min.metadata.ram ? product : min, ), ]; - const capacityChecks = productsToCheck.map((product) => - useServersFetch("stock", { - method: "POST", - body: { - cpu: product.metadata.cpu, - memory_mb: product.metadata.ram, - swap_mb: product.metadata.swap, - storage_mb: product.metadata.storage, - }, - bypassAuth: true, - }), - ); - - const results = await Promise.all(capacityChecks); + const capacityChecks = []; + for (const product of productsToCheck) { + capacityChecks.push( + useServersFetch("stock", { + method: "POST", + body: { + cpu: product.metadata.cpu, + memory_mb: product.metadata.ram, + swap_mb: product.metadata.swap, + storage_mb: product.metadata.storage, + }, + bypassAuth: true, + }), + ); + } 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);