Commit d9b969f6 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[tasks] specify whether app/tree reload is needed for async tasks

parent 995eae73
......@@ -55,7 +55,6 @@ type ReductorProps = (
type Reductor = R2.Reductor (Record ReductorProps) Action
type ReductorAction = Action -> Effect Unit
type OnFinish = Effect Unit
useTasks :: GT.ReloadS -> GT.ReloadS -> R.Hooks Reductor
useTasks appReload treeReload = R2.useReductor act initializer unit
......@@ -78,7 +77,14 @@ action p@{ treeReload, storage } (Insert nodeId t) = do
pure $ p { storage = newStorage }
action p (Finish nodeId t) = do
action p (Remove nodeId t)
action p@{ appReload, storage } (Remove nodeId t) = do
_ <- snd appReload $ (_ + 1)
action p@{ appReload, treeReload, storage } (Remove nodeId t@(GT.AsyncTaskWithType { typ })) = do
_ <- if GT.asyncTaskTriggersAppReload typ then
snd appReload $ (_ + 1)
else
pure unit
_ <- if GT.asyncTaskTriggersTreeReload typ then
snd treeReload $ (_ + 1)
else
pure unit
let newStorage = Map.alter (maybe Nothing $ (\ts -> Just $ removeTaskFromList ts t)) nodeId storage
pure $ p { storage = newStorage }
......@@ -126,7 +126,9 @@ treeLoadView = R.createElement elCpt
-- , tasks: tasksStruct root asyncTasks reload
, tree: loaded
} []
useLoader { root, counter: fst reload } fetch paint
useLoader { appCounter: fst appReload
, counter: fst reload
, root } fetch paint
--------------
getNodeTree :: Session -> GT.ID -> Aff FTree
......
......@@ -595,7 +595,7 @@ modeFromString _ = Nothing
-- corresponds to /add/form/async or /add/query/async
data AsyncTaskType = AddNode
| Form
| Form -- this is file upload too
| GraphRecompute
| Query
| UpdateNgramsCharts
......@@ -631,6 +631,14 @@ asyncTaskTypePath UpdateNgramsCharts = "ngrams/async/charts/update/"
asyncTaskTypePath UpdateNode = "update/"
asyncTaskTypePath UploadFile = "async/file/add/"
asyncTaskTriggersAppReload :: AsyncTaskType -> Boolean
asyncTaskTriggersAppReload _ = true
asyncTaskTriggersTreeReload :: AsyncTaskType -> Boolean
asyncTaskTriggersTreeReload Form = true
asyncTaskTriggersTreeReload UploadFile = true
asyncTaskTriggersTreeReload _ = false
type AsyncTaskID = String
......
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