fix: unnecessary runs of root layout.

This commit is contained in:
Darshan
2025-06-07 16:54:20 +05:30
parent 70b9bf2c22
commit e5a3052cb9
2 changed files with 18 additions and 12 deletions
+16 -2
View File
@@ -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<Models.ProjectList> {
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}>
<!-- <Header slot="header" />-->
<slot />
+2 -10
View File
@@ -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
};
};