diff --git a/extensions/apple-notes/CHANGELOG.md b/extensions/apple-notes/CHANGELOG.md index ca16d6fbccc..42dad4784be 100644 --- a/extensions/apple-notes/CHANGELOG.md +++ b/extensions/apple-notes/CHANGELOG.md @@ -1,5 +1,9 @@ # Apple Notes Changelog +## [Bug Fix Update] - 2024-05-16 + +Fix crashes caused by empty links or tags. + ## [Links, Backlinks, and Tags] - 2024-05-14 This update enhances the Apple Notes extension with several new features: diff --git a/extensions/apple-notes/src/components/NoteActions.tsx b/extensions/apple-notes/src/components/NoteActions.tsx index e19453c7039..db8a63d8ce5 100644 --- a/extensions/apple-notes/src/components/NoteActions.tsx +++ b/extensions/apple-notes/src/components/NoteActions.tsx @@ -115,7 +115,7 @@ export default function NoteActions({ noteTitles, note, isDeleted, isDetail, mut {note.links.length > 0 ? ( {note.links.map((link) => { - if (link.url) { + if (link.url && link.text) { return ( 0 ? ( - {note.tags.map((tag) => ( - - ))} + {note.tags.map((tag) => { + if (!tag.text) return null; + ; + })} ) : null} {note.links.length > 0 ? ( {note.links.map((link) => { const url = link.url; - if (url) { + const text = link.text; + if (url && text) { return ( - open(url)} /> + open(url)} /> ); } })} diff --git a/extensions/apple-notes/src/components/NoteListItem.tsx b/extensions/apple-notes/src/components/NoteListItem.tsx index e55a0d4af15..525083799ac 100644 --- a/extensions/apple-notes/src/components/NoteListItem.tsx +++ b/extensions/apple-notes/src/components/NoteListItem.tsx @@ -23,7 +23,12 @@ export default function NoteListItem({ note, noteTitles, isDeleted, mutate }: No text: `${note.tags.length}`, icon: Icon.Hashtag, // Display all tags inline and remove the leading # from the tag text - tooltip: `${note.tags.map((tag) => tag.text.slice(1)).join(", ")}`, + tooltip: `${note.tags + .map((tag) => { + if (!tag.text) return ""; + return tag.text.slice(1); + }) + .join(", ")}`, }); } @@ -96,7 +101,7 @@ export default function NoteListItem({ note, noteTitles, isDeleted, mutate }: No } if (note.tags) { - keywords.push(...note.tags.map((tag) => tag.text.slice(1))); + keywords.push(...note.tags.map((tag) => tag.text?.slice(1) ?? "")); } if (note.checklist) { diff --git a/extensions/apple-notes/src/useNotes.ts b/extensions/apple-notes/src/useNotes.ts index fda9da4ba70..e19a408bdcd 100644 --- a/extensions/apple-notes/src/useNotes.ts +++ b/extensions/apple-notes/src/useNotes.ts @@ -8,7 +8,7 @@ import { getOpenNoteURL } from "./helpers"; type Link = { id: string; - text: string; + text: string | null; url: string | null; notePk: number; }; @@ -21,7 +21,7 @@ type Backlink = { type Tag = { id: string; - text: string; + text: string | null; notePk: number; };