From b286ca35db7a6ce8587b7ca63d4d7127d8dbeebf Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 27 Aug 2024 13:59:26 +0200 Subject: [PATCH] fix: storage waterfall --- .../storage/bucket-[bucket]/+page.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/routes/(console)/project-[project]/storage/bucket-[bucket]/+page.ts b/src/routes/(console)/project-[project]/storage/bucket-[bucket]/+page.ts index 13eb6f5fee..59898b37fc 100644 --- a/src/routes/(console)/project-[project]/storage/bucket-[bucket]/+page.ts +++ b/src/routes/(console)/project-[project]/storage/bucket-[bucket]/+page.ts @@ -4,7 +4,6 @@ import { getLimit, getPage, getSearch, pageToOffset } from '$lib/helpers/load'; import { Dependencies, PAGE_LIMIT } from '$lib/constants'; import type { PageLoad } from './$types'; import { isCloud } from '$lib/system'; -import type { OrganizationUsage } from '$lib/sdk/billing'; export const load: PageLoad = async ({ params, depends, url, route, parent }) => { const { organization } = await parent(); @@ -13,20 +12,20 @@ export const load: PageLoad = async ({ params, depends, url, route, parent }) => const search = getSearch(url); const limit = getLimit(url, route, PAGE_LIMIT); const offset = pageToOffset(page, limit); - let organizationUsage: OrganizationUsage = null; - if (isCloud && organization?.$id) { - organizationUsage = await sdk.forConsole.billing.listUsage(organization.$id); - } - return { - offset, - limit, - search, - files: await sdk.forProject.storage.listFiles( + const [files, organizationUsage] = await Promise.all([ + sdk.forProject.storage.listFiles( params.bucket, [Query.limit(limit), Query.offset(offset), Query.orderDesc('')], search ), + isCloud && organization?.$id ? sdk.forConsole.billing.listUsage(organization.$id) : null + ]); + return { + offset, + limit, + search, + files, organizationUsage }; };