Handle deleting highlights in the notebook modal on PDFs

This commit is contained in:
Jackson Harper
2023-06-27 15:22:00 +08:00
parent 289405364b
commit 0d40f40eeb

View File

@ -316,14 +316,23 @@ export function NotebookContent(props: NotebookContentProps): JSX.Element {
message={'Are you sure you want to delete this highlight?'}
onAccept={() => {
;(async () => {
const highlightId = showConfirmDeleteHighlightId
const success = await deleteHighlightMutation(
showConfirmDeleteHighlightId
)
mutate()
if (success) {
showSuccessToast('Highlight deleted.')
showSuccessToast('Highlight deleted.', {
position: 'bottom-right',
})
const event = new CustomEvent('deleteHighlightbyId', {
detail: highlightId,
})
document.dispatchEvent(event)
} else {
showErrorToast('Error deleting highlight')
showErrorToast('Error deleting highlight', {
position: 'bottom-right',
})
}
})()
setShowConfirmDeleteHighlightId(undefined)