[ML] Lock the delete annotation button on click (#137306)

This commit is contained in:
Dima Arnautov 2022-07-28 09:10:26 +02:00 committed by GitHub
parent bcbef78b4d
commit b378c064c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -78,6 +78,8 @@ interface State {
}
export class AnnotationFlyoutUI extends Component<CommonProps & Props> {
private deletionInProgress = false;
public state: State = {
isDeleteModalVisible: false,
applyAnnotationToSeries: true,
@ -121,6 +123,8 @@ export class AnnotationFlyoutUI extends Component<CommonProps & Props> {
};
public deleteHandler = async () => {
if (this.deletionInProgress) return;
const { annotationState } = this.state;
const toastNotifications = getToastNotifications();
@ -128,6 +132,8 @@ export class AnnotationFlyoutUI extends Component<CommonProps & Props> {
return;
}
this.deletionInProgress = true;
try {
await ml.annotations.deleteAnnotation(annotationState._id);
toastNotifications.addSuccess(
@ -154,6 +160,8 @@ export class AnnotationFlyoutUI extends Component<CommonProps & Props> {
this.closeDeleteModal();
this.deletionInProgress = false;
const { annotationUpdatesService } = this.props;
annotationUpdatesService.setValue(null);