diff --git a/Workflow/app/notes/NotesList.tsx b/Workflow/app/notes/NotesList.tsx index 2edb092..a3a4143 100644 --- a/Workflow/app/notes/NotesList.tsx +++ b/Workflow/app/notes/NotesList.tsx @@ -20,19 +20,20 @@ export default function NotesList({ initialNotes }: Props) { const [editingId, setEditingId] = useState(null); const [error, setError] = useState(null); - // Sort: open first (created desc), then done (done_at desc). + // Sort: open first (id desc — newest first), then done (done_at desc, fallback id desc). const sorted = useMemo(() => { const open = notes .filter((n) => !n.is_done) .slice() - .sort((a, b) => (a.created < b.created ? 1 : -1)); + .sort((a, b) => (a.id < b.id ? 1 : -1)); const done = notes .filter((n) => n.is_done) .slice() .sort((a, b) => { - const ad = a.done_at ?? a.updated ?? a.created; - const bd = b.done_at ?? b.updated ?? b.created; - return ad < bd ? 1 : -1; + const ad = a.done_at ?? ""; + const bd = b.done_at ?? ""; + if (ad !== bd) return ad < bd ? 1 : -1; + return a.id < b.id ? 1 : -1; }); return [...open, ...done]; }, [notes]); diff --git a/Workflow/app/notes/page.tsx b/Workflow/app/notes/page.tsx index ad1b646..6740270 100644 --- a/Workflow/app/notes/page.tsx +++ b/Workflow/app/notes/page.tsx @@ -18,7 +18,7 @@ async function loadNotes(): Promise<{ notes: YsterbaardNote[]; error: string | n const list = await fetchCollection("ysterbaard_notes", { page: 1, perPage: 500, - sort: "-created", + sort: "-id", }); return { notes: list.items ?? [], error: null }; } catch (err) {