Sync highlight deletions on PDFs

This commit is contained in:
Jackson Harper 2023-02-02 14:19:15 +08:00
parent 49acfd71cb
commit f4d2726db7

View file

@ -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)
})