mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: reload regions on plan upgrades.
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
} from '@appwrite.io/pink-svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
import { onMount } from 'svelte';
|
||||
import { loadAvailableRegions } from '$routes/(console)/regions';
|
||||
import EstimatedTotalBox from '$lib/components/billing/estimatedTotalBox.svelte';
|
||||
|
||||
export let data;
|
||||
@@ -58,6 +59,7 @@
|
||||
afterNavigate(({ from }) => {
|
||||
previousPage = from?.url?.pathname || previousPage;
|
||||
});
|
||||
|
||||
onMount(async () => {
|
||||
if (page.url.searchParams.has('code')) {
|
||||
const coupon = page.url.searchParams.get('code');
|
||||
@@ -218,6 +220,11 @@
|
||||
}
|
||||
|
||||
if (isOrganization(org)) {
|
||||
/**
|
||||
* Reload on upgrade (e.g. Free → Paid)
|
||||
*/
|
||||
loadAvailableRegions(org.$id, true);
|
||||
|
||||
await invalidate(Dependencies.ACCOUNT);
|
||||
await invalidate(Dependencies.ORGANIZATION);
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@ let lastLoadedOrganization = null;
|
||||
*
|
||||
* Prevents unnecessary API calls if the regions are already loaded for the same organization.
|
||||
*/
|
||||
export async function loadAvailableRegions(orgId: string): Promise<void> {
|
||||
export async function loadAvailableRegions(orgId: string, force: boolean = false): Promise<void> {
|
||||
if (!isCloud || !orgId) return;
|
||||
|
||||
try {
|
||||
const storedRegions = get(regions);
|
||||
|
||||
if (storedRegions.regions && lastLoadedOrganization === orgId) {
|
||||
if (storedRegions.regions && lastLoadedOrganization === orgId && !force) {
|
||||
// already loaded for this organization, fast path return.
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user