Skip to content

Commit 57cdcb5

Browse files
committed
fix: reload regions on plan upgrades.
1 parent 2ed5507 commit 57cdcb5

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/routes/(console)/organization-[organization]/change-plan/+page.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
} from '@appwrite.io/pink-svelte';
3131
import { writable } from 'svelte/store';
3232
import { onMount } from 'svelte';
33+
import { loadAvailableRegions } from '$routes/(console)/regions';
3334
import EstimatedTotalBox from '$lib/components/billing/estimatedTotalBox.svelte';
3435
3536
export let data;
@@ -58,6 +59,7 @@
5859
afterNavigate(({ from }) => {
5960
previousPage = from?.url?.pathname || previousPage;
6061
});
62+
6163
onMount(async () => {
6264
if (page.url.searchParams.has('code')) {
6365
const coupon = page.url.searchParams.get('code');
@@ -218,6 +220,11 @@
218220
}
219221
220222
if (isOrganization(org)) {
223+
/**
224+
* Reload on upgrade (e.g. Free → Paid)
225+
*/
226+
loadAvailableRegions(org.$id, true);
227+
221228
await invalidate(Dependencies.ACCOUNT);
222229
await invalidate(Dependencies.ORGANIZATION);
223230

src/routes/(console)/regions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ let lastLoadedOrganization = null;
1010
*
1111
* Prevents unnecessary API calls if the regions are already loaded for the same organization.
1212
*/
13-
export async function loadAvailableRegions(orgId: string): Promise<void> {
13+
export async function loadAvailableRegions(orgId: string, force: boolean = false): Promise<void> {
1414
if (!isCloud || !orgId) return;
1515

1616
try {
1717
const storedRegions = get(regions);
1818

19-
if (storedRegions.regions && lastLoadedOrganization === orgId) {
19+
if (storedRegions.regions && lastLoadedOrganization === orgId && !force) {
2020
// already loaded for this organization, fast path return.
2121
return;
2222
}

0 commit comments

Comments
 (0)