@@ -2,11 +2,14 @@ import { Query, type Models } from '@appwrite.io/console';
22import { isCloud } from '$lib/system' ;
33import { sdk } from '$lib/stores/sdk' ;
44import { getLimit , getPage , getSearch , pageToOffset } from '$lib/helpers/load' ;
5+ import { listAllPages } from '$lib/helpers/pagination' ;
56import { CARD_LIMIT , Dependencies } from '$lib/constants' ;
67import type { PageLoad } from './$types' ;
78import { redirect } from '@sveltejs/kit' ;
89import { resolve } from '$app/paths' ;
910
11+ type Platform = Models . PlatformList [ 'platforms' ] [ number ] ;
12+
1013export const load : PageLoad = async ( { params, url, route, depends, parent } ) => {
1114 const { scopes } = await parent ( ) ;
1215 if ( ! scopes . includes ( 'projects.read' ) && scopes . includes ( 'billing.read' ) ) {
@@ -43,18 +46,30 @@ export const load: PageLoad = async ({ params, url, route, depends, parent }) =>
4346 ]
4447 } ) ;
4548
49+ const platformsByProjectId : Record < string , Platform [ ] > = { } ;
50+
51+ await Promise . all (
52+ activeProjects . projects . map ( async ( project ) => {
53+ const projectSdk = sdk . forProject ( project . region ?? 'default' , project . $id ) . project ;
54+ const platformList = await listAllPages (
55+ ( queries ) => projectSdk . listPlatforms ( { queries } ) ,
56+ 'platforms'
57+ ) ;
58+
59+ platformsByProjectId [ project . $id ] = platformList . platforms ;
60+ } )
61+ ) ;
62+
4663 // set `default` if no region!
4764 for ( const project of activeProjects . projects ) {
4865 project . region ??= 'default' ;
49- ( project as Models . Project & { platforms : Array < { type : string } > } ) . platforms = (
50- await sdk . forProject ( project . region , project . $id ) . project . listPlatforms ( )
51- ) . platforms ;
5266 }
5367
5468 return {
5569 limit,
5670 offset,
5771 search,
58- projects : activeProjects
72+ projects : activeProjects ,
73+ platformsByProjectId
5974 } ;
6075} ;
0 commit comments