diff --git a/src/services/notes.js b/src/services/notes.js index e5634df..653af57 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -36,7 +36,7 @@ export function updateNote(ownerId, id, input) { const patch = {}; if (input.title !== undefined) patch.title = requireString(input, 'title', { max: 120 }); if (input.body !== undefined) patch.body = requireString(input, 'body', { max: 10000 }); - if (input.tags !== undefined) patch.tags = input.tags && optionalTags(input); + if (input.tags !== undefined) patch.tags = optionalTags(input); invalidate(`notes:${ownerId}`); record(ownerId, 'note.update', id); return update('notes', id, patch); diff --git a/src/services/tags.js b/src/services/tags.js index a5a9ea2..d10f50e 100644 --- a/src/services/tags.js +++ b/src/services/tags.js @@ -7,7 +7,7 @@ export function tagCounts(ownerId) { const counts = {}; for (const note of all('notes')) { if (note.ownerId !== ownerId) continue; - for (const tag of note.tags) counts[tag] = (counts[tag] ?? 0) + 1; + for (const tag of note.tags ?? []) counts[tag] = (counts[tag] ?? 0) + 1; } return counts; }); diff --git a/src/utils/format.js b/src/utils/format.js index 24a3a09..230cc5d 100644 --- a/src/utils/format.js +++ b/src/utils/format.js @@ -19,7 +19,7 @@ export function noteSummary(note) { title: note.title, preview: truncate(note.body, 40), created: formatDate(note.createdAt), - tags: [...note.tags].sort(), + tags: [...(note.tags ?? [])].sort(), }; }