Make highlights optional

This commit is contained in:
Jackson Harper
2024-08-23 14:30:37 +08:00
parent fe1567fa78
commit d9c3437852

View File

@ -204,7 +204,7 @@ export default function PdfArticleContainer(
: null
if (highlightHref) {
// find the page index if possible
const highlight = props.article.highlights.find(
const highlight = props.article.highlights?.find(
(h) => h.id === highlightHref
)
if (highlight) {
@ -252,8 +252,8 @@ export default function PdfArticleContainer(
})
// Store the highlights in the highlightsRef and apply them to the PDF
highlightsRef.current = props.article.highlights
for (const highlight of props.article.highlights.filter(
highlightsRef.current = props.article.highlights ?? []
for (const highlight of (props.article.highlights ?? []).filter(
(h) => h.type == 'HIGHLIGHT'
)) {
const patch = JSON.parse(highlight.patch)