Skip to content

Commit

Permalink
fix: storage waterfall
Browse files Browse the repository at this point in the history
  • Loading branch information
TorstenDittmann committed Aug 27, 2024
1 parent fc9742f commit b286ca3
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
};
};

0 comments on commit b286ca3

Please sign in to comment.