fix: storage waterfall

This commit is contained in:
Torsten Dittmann
2024-08-27 13:59:26 +02:00
parent fc9742feb1
commit b286ca35db
@@ -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
};
};