Skip to content

Commit 496b6de

Browse files
authored
Merge pull request #2242 from appwrite/fix-regions-sorting
2 parents 1d8d122 + 110c45f commit 496b6de

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/lib/helpers/regions.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ export function filterRegions(regions: Models.ConsoleRegion[]): RegionOption[] {
1515
return regions
1616
.filter((region) => region.$id !== 'default')
1717
.sort((a, b) => {
18-
if (a.disabled && !b.disabled) return 1;
19-
if (!a.disabled && b.disabled) return -1;
18+
// Check if regions are truly available (not disabled and available)
19+
const aAvailable = !a.disabled && a.available;
20+
const bAvailable = !b.disabled && b.available;
21+
22+
// Prioritize truly available regions
23+
if (aAvailable && !bAvailable) return -1;
24+
if (!aAvailable && bAvailable) return 1;
25+
26+
// Within the same availability group, sort alphabetically
2027
return a.name.localeCompare(b.name);
2128
})
2229
.map((region) => ({

0 commit comments

Comments
 (0)