Fix cookie defaults and Timeline ordering, and give models a real Default (#573)

This commit is contained in:
Gregory Schier
2026-08-17 09:14:17 -07:00
committed by GitHub
parent 2021df112a
commit b89c448345
5 changed files with 349 additions and 60 deletions
+3 -1
View File
@@ -61,7 +61,9 @@ export function createOrderedModelAtom<M extends AnyModel["model"]>(
const modelData = data[modelType] ?? {};
return Object.values(modelData).sort(
(a: ExtractModel<AnyModel, M>, b: ExtractModel<AnyModel, M>) => {
const n = a[field] > b[field] ? 1 : -1;
// NOTE: ties must return 0, or the comparator is inconsistent and V8 reorders
// equal-keyed rows. Sort is stable, so 0 preserves store (DB) insertion order.
const n = a[field] === b[field] ? 0 : a[field] > b[field] ? 1 : -1;
return order === "desc" ? n * -1 : n;
},
);