mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Sync deletes of highlights
This commit is contained in:
parent
add720d523
commit
0c219ee789
1 changed files with 17 additions and 0 deletions
|
|
@ -546,6 +546,21 @@ export function HighlightsLayer(props: HighlightsLayerProps): JSX.Element {
|
|||
}
|
||||
}
|
||||
|
||||
const deleteHighlightById = useCallback(
|
||||
(event: Event) => {
|
||||
const annotationId = (event as CustomEvent).detail as string
|
||||
if (annotationId) {
|
||||
removeHighlights(
|
||||
highlights.map((h) => h.id),
|
||||
highlightLocations
|
||||
)
|
||||
const keptHighlights = highlights.filter(($0) => $0.id !== annotationId)
|
||||
setHighlights([...keptHighlights])
|
||||
}
|
||||
},
|
||||
[highlights, highlightLocations]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
const safeHandleAction = async (action: HighlightAction) => {
|
||||
try {
|
||||
|
|
@ -676,6 +691,7 @@ export function HighlightsLayer(props: HighlightsLayerProps): JSX.Element {
|
|||
document.addEventListener('setHighlightLabels', setHighlightLabels)
|
||||
document.addEventListener('scrollToNextHighlight', goToNextHighlight)
|
||||
document.addEventListener('scrollToPrevHighlight', goToPreviousHighlight)
|
||||
document.addEventListener('deleteHighlightbyId', deleteHighlightById)
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('annotate', annotate)
|
||||
|
|
@ -692,6 +708,7 @@ export function HighlightsLayer(props: HighlightsLayerProps): JSX.Element {
|
|||
'scrollToPrevHighlight',
|
||||
goToPreviousHighlight
|
||||
)
|
||||
document.removeEventListener('deleteHighlightbyId', deleteHighlightById)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue