fix: localeCompare will use $localStore and sort numeric

This commit is contained in:
Maxi Quoß
2025-03-16 10:57:08 +01:00
parent 583bf2181a
commit b779ca34a3
3 changed files with 8 additions and 6 deletions

View File

@@ -2,6 +2,7 @@
import { goto } from '$app/navigation';
import PageLoading from '$lib/components/PageLoading.svelte';
import { m } from '$lib/paraglide/messages';
import { localeStore } from '$lib/stores/locale';
import { backendUrl, pocketbase } from '$lib/stores/pocketbase';
import { settingsPriv } from '$lib/stores/settings';
import type { Device } from '$lib/types/device';
@@ -166,7 +167,7 @@
</div>
</div>
{#if scanResponse.devices?.length > 0}
{#each scanResponse.devices.sort( (a, b) => a.ip.localeCompare( b.ip, undefined, { numeric: true } ) ) as device, index}
{#each scanResponse.devices.sort( (a, b) => a.ip.localeCompare( b.ip, $localeStore, { numeric: true } ) ) as device, index}
<div class="collapse-arrow bg-base-100 collapse">
<input type="radio" name="scanned-devices" checked={index === 0} />
<div class="collapse-title font-bold">

View File

@@ -2,6 +2,7 @@
import DeviceCard from '$lib/components/DeviceCard.svelte';
import PageLoading from '$lib/components/PageLoading.svelte';
import { m } from '$lib/paraglide/messages';
import { localeStore } from '$lib/stores/locale';
import { permission, pocketbase } from '$lib/stores/pocketbase';
import type { Device, Group } from '$lib/types/device';
import {
@@ -138,16 +139,16 @@
<div class="space-y-6">
{#if devicesWithoutGroups().length > 0}
<div class={gridClass}>
{#each devicesWithoutGroups().sort( (a, b) => a[orderBy].localeCompare(b[orderBy]) ) as device}
{#each devicesWithoutGroups().sort( (a, b) => a[orderBy].localeCompare( b[orderBy], $localeStore, { numeric: true } ) ) as device}
<DeviceCard {device} />
{/each}
</div>
{/if}
{#each Object.entries(devicesWithGroup()).sort( ([a], [b]) => a.localeCompare(b) ) as [group, groupDevices]}
{#each Object.entries(devicesWithGroup()).sort( ([a], [b]) => a.localeCompare( b, $localeStore, { numeric: true } ) ) as [group, groupDevices]}
<div>
<h1 class="mb-3 text-2xl font-bold">{group}</h1>
<div class={gridClass}>
{#each groupDevices.sort((a, b) => a[orderBy].localeCompare(b[orderBy])) as device}
{#each groupDevices.sort( (a, b) => a[orderBy].localeCompare( b[orderBy], $localeStore, { numeric: true } ) ) as device}
<DeviceCard {device} />
{/each}
</div>
@@ -156,7 +157,7 @@
</div>
{:else}
<div class={gridClass}>
{#each filteredDevices().sort((a, b) => a[orderBy].localeCompare(b[orderBy])) as device}
{#each filteredDevices().sort( (a, b) => a[orderBy].localeCompare( b[orderBy], $localeStore, { numeric: true } ) ) as device}
<DeviceCard {device} />
{/each}
</div>

View File

@@ -179,7 +179,7 @@
</div>
<h2 class="card-title mt-4 mb-2">{m.account_language_title()}</h2>
<select class="select w-full max-w-xs" bind:value={selectedLang}>
{#each [...locales].sort( (a, b) => a.localeCompare( b, undefined, { sensitivity: 'base' } ) ) as lang}
{#each [...locales].sort( (a, b) => a.localeCompare( b, $localeStore, { sensitivity: 'base' } ) ) as lang}
<option value={lang} selected={$localeStore === lang}>
{languageEmojis[lang]}
{localeToFullName(lang)} [{lang}]