fix: initialize regions store as empty ConsoleRegionList

Using undefined as the initial value can lead to issues when trying to access the store such as:

TypeError: Cannot read properties of undefined (reading 'regions')
This commit is contained in:
Steven Nguyen committed 2025-05-27 17:28:03 -07:00
1 parent 71a82bfeaa
commit 333b812c82
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -61,4 +61,4 @@ export const organization = derived(page, ($page) => $page.data?.organization as
export const currentPlan = derived(page, ($page) => $page.data?.currentPlan as Plan);
export const members = derived(page, ($page) => $page.data.members as Models.MembershipList);
export const regions = writable<Models.ConsoleRegionList | undefined>(undefined);
export const regions = writable<Models.ConsoleRegionList>({ total: 0, regions: [] });
+1 -1
View File
@@ -16,7 +16,7 @@ export async function loadAvailableRegions(orgId: string): Promise<void> {
try {
const storedRegions = get(regions);
if (storedRegions?.regions && lastLoadedOrganization === orgId) {
if (storedRegions.regions && lastLoadedOrganization === orgId) {
// already loaded for this organization, fast path return.
return;
}