fix(tours): sorts that name their order, the note focused without autofocus

The checklist and the obstacle data sorted texts without a compare
function. They now sort by code units through one shared compareCodeUnits,
the order a bare sort gave, the same on every machine; the material data of
a lock's parts no longer orders by the server's locale, so its hash cannot
change with it. The note editor takes the focus through a ref instead of
autoFocus, a direct function reference in a map becomes a call, and the
GPX import's default fields are a named constant.
This commit is contained in:
Maurice
2026-10-17 03:18:04 +00:00
parent 9272151c07
commit 09caf4bc3f
10 changed files with 48 additions and 13 deletions
+3 -2
View File
@@ -1,3 +1,4 @@
import { compareCodeUnits } from '../common/compare';
import { haversineMetres } from '../geo/haversine';
import type { PaddleFeature } from '../paddle/paddle-obstacles.schema';
import { paddleLayoutOfPoints, paddleLayoutOfTrack, type PaddlePlanPoint } from './paddle-plan';
@@ -214,14 +215,14 @@ const isCosmetic = (key: string) => COSMETIC.has(key) || key.startsWith('check_d
/** The material data of an obstacle's members, as text to hash: what they are and the tags that bear on passing. */
export function materialOf(members: readonly PaddleFeature[]): string {
const rows = [...members]
.sort((a, b) => a.ref.localeCompare(b.ref))
.sort((a, b) => compareCodeUnits(a.ref, b.ref))
.map((member) => [
member.ref,
member.kind,
member.geometry.type,
Object.keys(member.tags)
.filter((key) => !isCosmetic(key))
.sort()
.sort(compareCodeUnits)
.map((key) => [key, member.tags[key]]),
]);
return JSON.stringify(rows);
+3 -2
View File
@@ -1,3 +1,4 @@
import { compareCodeUnits } from '../common/compare';
import {
PADDLE_BLOCKING_KINDS,
paddleAccessOf,
@@ -166,7 +167,7 @@ function localCheckOf(members: readonly PaddleFeature[]): string | null {
)
.map(([, value]) => value),
);
const sorted = dates.sort();
const sorted = dates.sort(compareCodeUnits);
return sorted[sorted.length - 1] ?? null;
}
@@ -239,7 +240,7 @@ export function obstacleCandidatesOf(input: {
...members
.map((member) => member.ref)
.filter((ref) => ref !== anchor.feature.ref)
.sort(),
.sort(compareCodeUnits),
].slice(0, OBSTACLE_REFS_MAX),
kind,
name: anchor.feature.name ?? members.find((member) => member.name)?.name ?? null,