Skip to content

Commit c36dd1d

Browse files
committed
fix: invalidation issue causing null organization on project's first creation.
1 parent dfa7c52 commit c36dd1d

File tree

6 files changed

+25
-14
lines changed

6 files changed

+25
-14
lines changed

src/lib/components/billing/selectPaymentMethod.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
3232
await Promise.all([
3333
invalidate(Dependencies.UPGRADE_PLAN),
34-
invalidate(Dependencies.CREATE_ORGANIZATION)
34+
invalidate(Dependencies.ORGANIZATION)
3535
]);
3636
}
3737

src/lib/components/breadcrumbs.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@
101101
102102
async function createProjectsBottomSheet(organization: Organization): Promise<SheetMenu> {
103103
isLoadingProjects = true;
104-
loadedProjects = await projects;
104+
// null on non-org/project path like `onboarding`.
105+
loadedProjects = (await projects) ?? loadedProjects;
105106
isLoadingProjects = false;
106107
107108
const createProjectItem = {

src/routes/(console)/+layout.svelte

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,19 @@
316316
317317
$: checkForUsageLimits($organization);
318318
319-
$: projects = sdk.forConsole.projects.list([
320-
Query.equal(
321-
'teamId',
322-
// id from page params ?? id from store ?? id from preferences
323-
page.params.organization ?? currentOrganizationId ?? data.currentOrgId
324-
),
325-
Query.limit(5),
326-
Query.orderDesc('$updatedAt')
327-
]);
319+
$: isOnOnboarding = page.route?.id?.includes('/(console)/onboarding');
320+
321+
$: projects = isOnOnboarding
322+
? null
323+
: sdk.forConsole.projects.list([
324+
Query.equal(
325+
'teamId',
326+
// id from page params ?? id from store ?? id from preferences
327+
page.params.organization ?? currentOrganizationId ?? data.currentOrgId
328+
),
329+
Query.limit(5),
330+
Query.orderDesc('$updatedAt')
331+
]);
328332
329333
$: if ($requestedMigration) {
330334
openMigrationWizard();

src/routes/(console)/create-organization/+page.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import type { Coupon } from '$lib/sdk/billing';
55
import type { Organization } from '$lib/stores/organization';
66

77
export const load: PageLoad = async ({ url, parent, depends }) => {
8-
depends(Dependencies.CREATE_ORGANIZATION);
98
const { organizations } = await parent();
9+
depends(Dependencies.CREATE_ORGANIZATION);
10+
1011
const [coupon, paymentMethods] = await Promise.all([
1112
getCoupon(url),
1213
sdk.forConsole.billing.listPaymentMethods()

src/routes/(console)/onboarding/create-organization/+page.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
import { isCloud } from '$lib/system';
33
import { sdk } from '$lib/stores/sdk';
44
import { ID } from '@appwrite.io/console';
5-
import { BillingPlan } from '$lib/constants';
5+
import { BillingPlan, Dependencies } from '$lib/constants';
66
import { tierToPlan } from '$lib/stores/billing';
77
import { addNotification } from '$lib/stores/notifications';
88
import { loadAvailableRegions } from '$routes/(console)/regions';
99
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
1010
import { Button, Card, Layout, Input, Typography, Spinner } from '@appwrite.io/pink-svelte';
1111
import { Form } from '$lib/elements/forms/index.js';
12-
import { goto } from '$app/navigation';
12+
import { goto, invalidate } from '$app/navigation';
1313
import { base } from '$app/paths';
1414
1515
let isLoading = false;
@@ -47,6 +47,10 @@
4747
if (organization) {
4848
loadAvailableRegions(organization?.$id).then();
4949
await goto(`${base}/organization-${organization.$id}`);
50+
51+
// fixes an edge case where
52+
// the org is not available for some reason!
53+
await invalidate(Dependencies.CREATE_ORGANIZATION);
5054
}
5155
isLoading = false;
5256
}

src/routes/+layout.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const ssr = false;
1616

1717
export const load: LayoutLoad = async ({ depends, url, route }) => {
1818
depends(Dependencies.ACCOUNT);
19+
depends(Dependencies.CREATE_ORGANIZATION);
1920

2021
const [account, error] = (await sdk.forConsole.account
2122
.get()

0 commit comments

Comments
 (0)