From f4d2726db722427a94f193207b7716a028f3ddcb Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 2 Feb 2023 14:19:15 +0800 Subject: [PATCH] Sync highlight deletions on PDFs --- .../templates/article/PdfArticleContainer.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/web/components/templates/article/PdfArticleContainer.tsx b/packages/web/components/templates/article/PdfArticleContainer.tsx index 08bcdceb2..2449a0d7a 100644 --- a/packages/web/components/templates/article/PdfArticleContainer.tsx +++ b/packages/web/components/templates/article/PdfArticleContainer.tsx @@ -136,14 +136,25 @@ export default function PdfArticleContainer( id: 'tooltip-remove-annotation', className: 'TooltipItem-Remove', onPress: () => { + const annotationId = annotationOmnivoreId(annotation) + instance .delete(annotation) .then(() => { - const annotationId = annotationOmnivoreId(annotation) if (annotationId) { return deleteHighlightMutation(annotationId) } }) + .then(() => { + const highlightIdx = highlightsRef.current.findIndex( + (value) => { + return value.id == annotationId + } + ) + if (highlightIdx > -1) { + highlightsRef.current.splice(highlightIdx, 1) + } + }) .catch((err) => { showErrorToast('Error deleting highlight: ' + err) })