From 1fc918b1cd7a6611487b4fc1305052ab858d8ed9 Mon Sep 17 00:00:00 2001
From: Valentin Perrelle <valentin.perrelle@cea.fr>
Date: Tue, 25 Apr 2023 19:21:58 +0200
Subject: [PATCH] [Ivette] Reset the "acknowledged that the analysis has been
 aborted" button for each new analysis

---
 .../frama-c/plugins/eva/EvaReady/index.tsx    | 23 +++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/ivette/src/frama-c/plugins/eva/EvaReady/index.tsx b/ivette/src/frama-c/plugins/eva/EvaReady/index.tsx
index 4672816c59e..c35354ba723 100644
--- a/ivette/src/frama-c/plugins/eva/EvaReady/index.tsx
+++ b/ivette/src/frama-c/plugins/eva/EvaReady/index.tsx
@@ -20,7 +20,7 @@
 /*                                                                          */
 /* ************************************************************************ */
 
-import React from 'react';
+import React, { useEffect } from 'react';
 import { GlobalState, useGlobalState } from 'dome/data/states';
 import * as States from 'frama-c/states';
 import { Button } from 'dome/controls/buttons';
@@ -29,13 +29,32 @@ import Gallery from 'dome/controls/gallery.json';
 
 import gearsIcon from '../images/gears.svg';
 import './style.css';
+import { onSignal } from 'frama-c/server';
 
-const ackAbortedState = new GlobalState(false);
+class AckAbortedState extends GlobalState<boolean> {
+  #signalHookSet = false;
+
+  constructor(initValue: boolean) {
+    super(initValue);
+  }
+
+  setupSignalHooks(): void {
+    if (!this.#signalHookSet) {
+      onSignal(Eva.signalComputationState,
+        () => ackAbortedState.setValue(false));
+      this.#signalHookSet = true;
+    }
+  }
+}
+
+const ackAbortedState = new AckAbortedState(false);
 
 const EvaReady: React.FC = ({ children }) => {
   const state = States.useSyncValue(Eva.computationState);
   const [ackAborted, setAckAborted] = useGlobalState(ackAbortedState);
 
+  useEffect(() => ackAbortedState.setupSignalHooks());
+
   switch (state) {
     case undefined:
     case 'not_computed': {
-- 
GitLab