@@ -45,6 +45,7 @@ import {
4545} from '#/lib/queries/checklists.ts' ;
4646import type { IdentifiedTimestampedNote as ApiNote } from '#/types/notes' ;
4747import type { IdentifiedChecklist as ApiChecklist } from '#/types/checklist' ;
48+ import { genId } from '#/lib/utils' ;
4849
4950// ── Types ──────────────────────────────────────────────────────
5051
@@ -54,7 +55,7 @@ type NoteType = 'note' | 'checklist';
5455/**
5556 * A single item within a checklist.
5657 * `id` can be a **number** (persisted via API, used for toggling completion) or a
57- * **string** (locally generated via `crypto.randomUUID ()` for items not yet saved).
58+ * **string** (locally generated via `genId ()` for items not yet saved).
5859 * The form uses this distinction: numeric IDs map to API items, string IDs are new
5960 * items that will be created via `addChecklistItem`.
6061 */
@@ -438,7 +439,7 @@ function NoteDetail({
438439
439440/**
440441 * Create / Edit form. Type is locked when editing (cannot convert note ↔ checklist).
441- * New checklist items get `crypto.randomUUID ()` string IDs; persisted items have
442+ * New checklist items get `genId ()` string IDs; persisted items have
442443 * numeric IDs. Enter in "Add item" input triggers `addItem`.
443444 */
444445function NoteForm ( {
@@ -459,7 +460,7 @@ function NoteForm({
459460 /** Add a new checklist item with a local UUID string ID. */
460461 const addItem = ( ) => {
461462 if ( ! newItemText . trim ( ) ) return ;
462- setItems ( [ ...items , { id : crypto . randomUUID ( ) , text : newItemText . trim ( ) , done : false } ] ) ;
463+ setItems ( [ ...items , { id : genId ( ) , text : newItemText . trim ( ) , done : false } ] ) ;
463464 setNewItemText ( '' ) ;
464465 } ;
465466
@@ -563,7 +564,7 @@ function NoteForm({
563564 * is derived via `useMemo` from the live list to avoid stale snapshots.
564565 *
565566 * Checklist save: computes diff between original and form items — numeric IDs
566- * absent from form are deleted, string IDs (from `crypto.randomUUID ()`) are created.
567+ * absent from form are deleted, string IDs (from `genId ()`) are created.
567568 */
568569export function NotesPage ( ) {
569570 const router = useRouter ( ) ;
@@ -712,7 +713,7 @@ export function NotesPage() {
712713 * calls in parallel via `Promise.all`.
713714 * **Existing checklist update**: Computes a diff against the original items:
714715 * - Items with numeric IDs in the original but absent from the form → deleted.
715- * - Items with string IDs (local `crypto.randomUUID ()` → created via API.
716+ * - Items with string IDs (local `genId ()` → created via API.
716717 * - The checklist title is updated unconditionally.
717718 * This diff-based approach avoids deleting and recreating unchanged items,
718719 * preserving their server-side IDs and creation timestamps.
@@ -781,7 +782,7 @@ export function NotesPage() {
781782 ) ;
782783 }
783784
784- // Add new items (string ids from crypto.randomUUID )
785+ // Add new items (string ids from genId )
785786 const newItems = note . checklist . filter ( ( item ) => typeof item . id === 'string' ) ;
786787 if ( newItems . length > 0 ) {
787788 await Promise . all (
0 commit comments