diff --git a/src/routes/(console)/+layout.svelte b/src/routes/(console)/+layout.svelte index cf882f53c..1d40e91e3 100644 --- a/src/routes/(console)/+layout.svelte +++ b/src/routes/(console)/+layout.svelte @@ -36,7 +36,7 @@ import { stripe } from '$lib/stores/stripe'; import MobileSupportModal from './wizard/support/mobileSupportModal.svelte'; import { showSupportModal } from './wizard/support/store'; - import { activeHeaderAlert, consoleVariables, version } from './store'; + import { activeHeaderAlert, consoleVariables } from './store'; import { headerAlert } from '$lib/stores/headerAlert'; import { UsageRates } from '$lib/components/billing'; import { base } from '$app/paths'; @@ -54,6 +54,7 @@ } from '@appwrite.io/pink-icons-svelte'; import type { LayoutData } from './$types'; import { sdk } from '$lib/stores/sdk'; + import { type Models, Query } from '@appwrite.io/console'; export let data: LayoutData; @@ -313,6 +314,19 @@ $: checkForUsageLimits($organization); + function getProjectsPromise(): Promise { + return sdk.forConsole.projects.list([ + Query.equal( + 'teamId', + data.currentOrgId ?? currentOrganizationId ?? page.params.organization + ), + Query.limit(5), + Query.orderDesc('$updatedAt') + ]); + } + + $: projectsPromise = getProjectsPromise(); + $: if ($requestedMigration) { openMigrationWizard(); } @@ -333,7 +347,7 @@ !page.url.pathname.includes('/console/onboarding')} showHeader={!page.url.pathname.includes('/console/onboarding/create-project')} showFooter={!page.url.pathname.includes('/console/onboarding/create-project')} - projectsPromise={data.projectsPromise} + projectsPromise={projectsPromise} selectedProject={page.data?.project}> diff --git a/src/routes/(console)/+layout.ts b/src/routes/(console)/+layout.ts index 1a24acc52..183aece47 100644 --- a/src/routes/(console)/+layout.ts +++ b/src/routes/(console)/+layout.ts @@ -1,12 +1,11 @@ import { sdk } from '$lib/stores/sdk'; import { isCloud } from '$lib/system'; import type { LayoutLoad } from './$types'; -import { Query } from '@appwrite.io/console'; import { Dependencies } from '$lib/constants'; import type { Tier } from '$lib/stores/billing'; import type { Plan, PlanList } from '$lib/sdk/billing'; -export const load: LayoutLoad = async ({ params, depends, parent }) => { +export const load: LayoutLoad = async ({ depends, parent }) => { await parent(); depends(Dependencies.RUNTIMES); depends(Dependencies.CONSOLE_VARIABLES); @@ -27,7 +26,6 @@ export const load: LayoutLoad = async ({ params, depends, parent }) => { const plansInfo = toPlanMap(plansArray); const currentOrgId = - params.organization ?? preferences.organization ?? (organizations.teams.length > 0 ? organizations.teams[0].$id : undefined); @@ -39,13 +37,7 @@ export const load: LayoutLoad = async ({ params, depends, parent }) => { currentOrgId, organizations, consoleVariables, - version: versionData?.version ?? null, - currentProjectId: params.project ?? '', - projectsPromise: sdk.forConsole.projects.list([ - Query.equal('teamId', currentOrgId), - Query.limit(5), - Query.orderDesc('$updatedAt') - ]) + version: versionData?.version ?? null }; };