Commit 27314c4f authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge remote-tracking branch 'origin/728-dev-csv-upload-error-message' into dev

parents 84be6407 4a8000d8
Pipeline #7460 passed with stages
in 29 minutes and 5 seconds
...@@ -3,6 +3,7 @@ module Gargantext.AsyncTasks ...@@ -3,6 +3,7 @@ module Gargantext.AsyncTasks
, TaskList , TaskList
, Storage(..) , Storage(..)
, insert , insert
, hasTask
, finish , finish
, focus , focus
-- , asyncTaskTTriggersAppReload -- , asyncTaskTTriggersAppReload
...@@ -78,6 +79,14 @@ insert id task storageBox = modifyTaskBox newStorage storageBox ...@@ -78,6 +79,14 @@ insert id task storageBox = modifyTaskBox newStorage storageBox
where where
newStorage (Storage s) = Storage $ Map.alter (maybe (Just [ task ]) (\ts -> Just $ A.nub $ A.cons task ts)) id s newStorage (Storage s) = Storage $ Map.alter (maybe (Just [ task ]) (\ts -> Just $ A.nub $ A.cons task ts)) id s
hasTask :: GT.NodeID -> Task -> T.Box Storage -> Effect Boolean
hasTask id (GT.WorkerTask { message_id }) storage = do
Storage storage' <- T.read storage
case Map.lookup id storage' of
Nothing -> pure false
Just taskList ->
pure $ A.any (\(GT.WorkerTask { message_id: mId }) -> mId == message_id) taskList
finish :: GT.NodeID -> Task -> T.Box Storage -> Effect Unit finish :: GT.NodeID -> Task -> T.Box Storage -> Effect Unit
finish id task storage = remove id task storage finish id task storage = remove id task storage
......
...@@ -31,6 +31,7 @@ import Gargantext.Components.Lang (Lang(EN)) ...@@ -31,6 +31,7 @@ import Gargantext.Components.Lang (Lang(EN))
import Gargantext.Components.Nodes.Corpus.Types (CorpusData) import Gargantext.Components.Nodes.Corpus.Types (CorpusData)
import Gargantext.Components.Notifications as Notifications import Gargantext.Components.Notifications as Notifications
import Gargantext.Components.Notifications.Types as NT import Gargantext.Components.Notifications.Types as NT
import Gargantext.Config.Utils (handleErrorInAsyncTaskLog)
import Gargantext.Context.Progress (asyncContext, asyncProgress) import Gargantext.Context.Progress (asyncContext, asyncProgress)
import Gargantext.Ends (Frontends, url) import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
...@@ -258,9 +259,16 @@ nodeSpanCpt = here.component "nodeSpan" cpt ...@@ -258,9 +259,16 @@ nodeSpanCpt = here.component "nodeSpan" cpt
void $ setTimeout 400 $ T2.reload reload void $ setTimeout 400 $ T2.reload reload
NT.NUpdateWorkerProgress ji atl -> do NT.NUpdateWorkerProgress ji atl -> do
-- TODO Fire this only once! -- TODO Fire this only once!
-- here.log3 "[nodeSpan] update job progress" ji atl here.log3 "[nodeSpan] update job progress" ji atl
if GT.asyncTaskLogIsFinished atl then pure unit if GT.asyncTaskLogIsFinished atl then do
else -- Handle error but only when the task is not already in the storage
-- (we want to avoid reporting the error multiple times, from different places).
-- See e.g. https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/728
-- (error is thrown before the task marks any progress)
hasTask <- GAT.hasTask props.id ji boxes.tasks
unless hasTask $ do
handleErrorInAsyncTaskLog boxes.errors atl
else do
GAT.insert props.id ji boxes.tasks GAT.insert props.id ji boxes.tasks
_ -> pure unit _ -> pure unit
ws <- T.read boxes.wsNotification ws <- T.read boxes.wsNotification
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment