Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix: annotation deletion race condition

Blue Mouseada02b58d664
diff --git a/web/app/pages/Project/View/ViewProject.tsx b/web/app/pages/Project/View/ViewProject.tsx
index df61de32f..bb9088ac3 100644
--- a/web/app/pages/Project/View/ViewProject.tsx
+++ b/web/app/pages/Project/View/ViewProject.tsx
@@ -777,15 +777,17 @@ const ViewProjectContent = () => {
setAnnotationActionLoading(false)
}
- const onAnnotationDelete = async () => {
- if (annotationActionLoading || !annotationToEdit) {
+ const onAnnotationDelete = async (annotation?: Annotation) => {
+ const targetAnnotation = annotation || annotationToEdit
+
+ if (annotationActionLoading || !targetAnnotation) {
return
}
setAnnotationActionLoading(true)
try {
- await deleteAnnotation(annotationToEdit.id, id)
+ await deleteAnnotation(targetAnnotation.id, id)
await loadAnnotations()
toast.success(t('apiNotifications.annotationDeleted'))
} catch (reason: any) {
@@ -4753,8 +4755,7 @@ const ViewProjectContent = () => {
onDeleteAnnotation={
contextMenu.annotation
? () => {
- setAnnotationToEdit(contextMenu.annotation!)
- onAnnotationDelete()
+ onAnnotationDelete(contextMenu.annotation!)
}
: undefined
}