-
Notifications
You must be signed in to change notification settings - Fork 235
perf: eliminate wasted API call, afterUpdate overhead, and sequential billing checks #3026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ | |
| import { database, checkForDatabaseBackupPolicies } from '$lib/stores/database'; | ||
| import { newOrgModal, organization } from '$lib/stores/organization'; | ||
| import { wizard } from '$lib/stores/wizard'; | ||
| import { afterUpdate, onMount } from 'svelte'; | ||
| import { onMount } from 'svelte'; | ||
| import { loading } from '$routes/store'; | ||
| import { requestedMigration } from '../store'; | ||
| import Create from './createOrganization.svelte'; | ||
|
|
@@ -280,10 +280,12 @@ | |
| } | ||
| } | ||
|
|
||
| database.subscribe(async (database) => { | ||
| if (!database || !page.params.region || !page.params.project) return; | ||
| // the component checks `isCloud` internally. | ||
| await checkForDatabaseBackupPolicies(page.params.region, page.params.project, database); | ||
| onMount(() => { | ||
| return database.subscribe(async (database) => { | ||
| if (!database || !page.params.region || !page.params.project) return; | ||
| // the component checks `isCloud` internally. | ||
| await checkForDatabaseBackupPolicies(page.params.region, page.params.project, database); | ||
| }); | ||
| }); | ||
|
|
||
| let currentOrganizationId = null; | ||
|
|
@@ -293,18 +295,21 @@ | |
| if (isCloud) { | ||
| currentOrganizationId = org.$id; | ||
| checkForEnterpriseTrial(org); | ||
| await checkForUsageLimit(org); | ||
| checkForMarkedForDeletion(org); | ||
| await checkForNewDevUpgradePro(org); | ||
|
|
||
| if (org?.billingPlanDetails.requiresPaymentMethod) { | ||
| await paymentExpired(org); | ||
| await checkPaymentAuthorizationRequired(org); | ||
| const billingChecks: Promise<unknown>[] = [ | ||
| checkForUsageLimit(org), | ||
| checkForNewDevUpgradePro(org) | ||
| ]; | ||
|
|
||
| if (org?.billingPlanDetails.requiresPaymentMethod) { | ||
| billingChecks.push(paymentExpired(org), checkPaymentAuthorizationRequired(org)); | ||
| if (org?.billingTrialDays) { | ||
| calculateTrialDay(org); | ||
| } | ||
| } | ||
|
|
||
| await Promise.all(billingChecks); | ||
| $activeHeaderAlert = headerAlert.getExcluding('impersonation'); | ||
| } | ||
| } | ||
|
|
@@ -317,9 +322,7 @@ | |
|
|
||
| $registerSearchers(orgSearcher, projectsSearcher); | ||
|
|
||
| afterUpdate(() => { | ||
| $activeHeaderAlert = headerAlert.getExcluding('impersonation'); | ||
| }); | ||
| $: (void $headerAlert, ($activeHeaderAlert = headerAlert.getExcluding('impersonation'))); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The comma expression Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| </script> | ||
|
|
||
| <CommandCenter /> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onMountblocks in the same componentThere are now two
onMountcalls in this component (lines 253 and 283). While Svelte allows multipleonMountregistrations, having two separate blocks for the same component lifecycle event makes the initialization flow harder to follow. Thedatabase.subscribesetup could be placed inside the existingonMountblock at line 253 to keep all mounting logic in one place.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!