diff --git a/src/Gargantext/Components/App.purs b/src/Gargantext/Components/App.purs index 77f463822ca29715b06b878a932ea08a9cba4913..6e002aa6cec4948a57901387607c81cd8688975a 100644 --- a/src/Gargantext/Components/App.purs +++ b/src/Gargantext/Components/App.purs @@ -25,12 +25,12 @@ appCpt = here.component "app" cpt where cpt _ _ = do box <- T.useBox emptyApp -- global data boxes <- T.useFocusedFields box {} -- read-write access for children - tasks <- T.useBox Nothing -- storage for asynchronous tasks reductor + -- tasks <- T.useBox Nothing -- storage for asynchronous tasks reductor R.useEffectOnce' $ do void $ Sessions.load boxes.sessions - tasksReductor <- GAT.useTasks boxes.reloadRoot boxes.reloadForest - R.useEffectOnce' $ do - T.write (Just tasksReductor) tasks + tasks <- GAT.useTasks boxes.reloadRoot boxes.reloadForest + -- R.useEffectOnce' $ do + -- T.write (Just tasksReductor) tasks R.useEffectOnce' $ do R2.loadLocalStorageState R2.openNodesKey boxes.forestOpen T.listen (R2.listenLocalStorageState R2.openNodesKey) boxes.forestOpen diff --git a/src/Gargantext/Components/Forest.purs b/src/Gargantext/Components/Forest.purs index f6f6553cfa662d28279a0822851ac015a5520ad0..7c7adea2315c863670f0bf044e4b75edb062adff 100644 --- a/src/Gargantext/Components/Forest.purs +++ b/src/Gargantext/Components/Forest.purs @@ -33,11 +33,12 @@ here = R2.here "Gargantext.Components.Forest" -- Shared by components here with Tree type Common = - ( frontends :: Frontends - , handed :: T.Box Handed - , reloadRoot :: T.Box T2.Reload - , route :: T.Box AppRoute - , tasks :: T.Box (Maybe GAT.Reductor) + ( frontends :: Frontends + , handed :: T.Box Handed + , reloadRoot :: T.Box T2.Reload + , route :: T.Box AppRoute + -- , tasks :: T.Box (Maybe GAT.Reductor) + , tasks :: GAT.Reductor ) type Props = @@ -69,29 +70,32 @@ forestCpt = here.component "forest" cpt where , sessions , showLogin , tasks } _ = do - tasks' <- GAT.useTasks reloadRoot reloadForest - R.useEffect' $ T.write_ (Just tasks') tasks + -- TODO Fix this. I think tasks shouldn't be a Box but only a Reductor + -- tasks' <- GAT.useTasks reloadRoot reloadForest + -- R.useEffect' $ do + -- T.write_ (Just tasks') tasks handed' <- T.useLive T.unequal handed reloadForest' <- T.useLive T.unequal reloadForest reloadRoot' <- T.useLive T.unequal reloadRoot route' <- T.useLive T.unequal route forestOpen' <- T.useLive T.unequal forestOpen sessions' <- T.useLive T.unequal sessions + -- TODO If `reloadForest` is set, `reload` state should be updated -- TODO fix tasks ref -- R.useEffect' $ do -- R.setRef tasks $ Just tasks' R2.useCache ( frontends /\ route' /\ sessions' /\ handed' /\ forestOpen' - /\ reloadForest' /\ reloadRoot' /\ (fst tasks').storage ) - (cp handed' sessions' tasks') + /\ reloadForest' /\ reloadRoot' /\ (fst tasks).storage ) + (cp handed' sessions') where common = RX.pick props :: Record Common - cp handed' sessions' tasks' _ = + cp handed' sessions' _ = pure $ H.div { className: "forest" } - (A.cons (plus handed' showLogin backend) (trees handed' sessions' tasks')) - trees handed' sessions' tasks' = (tree handed' tasks') <$> unSessions sessions' - tree handed' tasks' s@(Session {treeId}) = + (A.cons (plus handed' showLogin backend) (trees handed' sessions')) + trees handed' sessions' = (tree handed') <$> unSessions sessions' + tree handed' s@(Session {treeId}) = treeLoader { forestOpen , frontends , handed: handed' @@ -193,7 +197,7 @@ mainPage = R.createElement mainPageCpt -- mainPageCpt :: R.Memo () -- mainPageCpt = R.memo (here.component "mainPage" cpt) where -mainPageCpt :: R.Component() +mainPageCpt :: R.Component () mainPageCpt = here.component "mainPage" cpt where cpt _ children = do diff --git a/src/Gargantext/Components/Forest/Tree.purs b/src/Gargantext/Components/Forest/Tree.purs index 2216cc59f7413fed0f38aec89676dde542bba6b0..4598c1c11ba9952e18c4ce3b32cbc0e2720bfff8 100644 --- a/src/Gargantext/Components/Forest/Tree.purs +++ b/src/Gargantext/Components/Forest/Tree.purs @@ -48,7 +48,8 @@ here = R2.here "Gargantext.Components.Forest.Tree" -- Shared by every component here + performAction + nodeSpan type Universal = ( reloadRoot :: T.Box T2.Reload - , tasks :: T.Box (Maybe GAT.Reductor) ) + -- , tasks :: T.Box (Maybe GAT.Reductor) ) + , tasks :: GAT.Reductor ) -- Shared by every component here + nodeSpan type Global = @@ -178,19 +179,13 @@ performAction (DeleteNode nt) p@{ forestOpen performAction RefreshTree p performAction (DoSearch task) p@{ tasks , tree: (NTree (LNode {id}) _) } = liftEffect $ do - mT <- T.read tasks - case mT of - Just t -> snd t $ GAT.Insert id task - Nothing -> pure unit + snd tasks $ GAT.Insert id task log2 "[performAction] DoSearch task:" task performAction (UpdateNode params) p@{ tasks , tree: (NTree (LNode {id}) _) } = do task <- updateRequest params p.session id liftEffect $ do - mT <- T.read tasks - case mT of - Just t -> snd t $ GAT.Insert id task - Nothing -> pure unit + snd tasks $ GAT.Insert id task log2 "[performAction] UpdateNode task:" task performAction (RenameNode name) p@{ tree: (NTree (LNode {id}) _) } = do void $ rename p.session id $ RenameValue { text: name } @@ -213,19 +208,13 @@ performAction (UploadFile nodeType fileType mName blob) p@{ tasks , tree: (NTree (LNode { id }) _) } = do task <- uploadFile p.session nodeType id fileType {mName, blob} liftEffect $ do - mT <- T.read tasks - case mT of - Just t -> snd t $ GAT.Insert id task - Nothing -> pure unit + snd tasks $ GAT.Insert id task log2 "[performAction] UploadFile, uploaded, task:" task performAction (UploadArbitraryFile mName blob) p@{ tasks , tree: (NTree (LNode { id }) _) } = do task <- uploadArbitraryFile p.session id { blob, mName } liftEffect $ do - mT <- T.read tasks - case mT of - Just t -> snd t $ GAT.Insert id task - Nothing -> pure unit + snd tasks $ GAT.Insert id task log2 "[performAction] UploadArbitraryFile, uploaded, task:" task performAction DownloadNode _ = liftEffect $ log "[performAction] DownloadNode" performAction (MoveNode {params}) p@{ forestOpen diff --git a/src/Gargantext/Components/Forest/Tree/Node.purs b/src/Gargantext/Components/Forest/Tree/Node.purs index d38838a7a63000ae7528836b434206fab74dc7a0..ebf0688b331889979b7ee190c467f0e7ed5beb2f 100644 --- a/src/Gargantext/Components/Forest/Tree/Node.purs +++ b/src/Gargantext/Components/Forest/Tree/Node.purs @@ -5,7 +5,7 @@ import Gargantext.Prelude import Data.Maybe (Maybe(..)) import Data.Nullable (null) import Data.Symbol (SProxy(..)) -import Data.Tuple (snd) +import Data.Tuple (fst, snd) import Data.Tuple.Nested ((/\)) import Effect (Effect) import Effect.Aff (Aff, launchAff) @@ -54,7 +54,7 @@ type NodeMainSpanProps = , reloadRoot :: T.Box T2.Reload , route :: T.Box Routes.AppRoute , setPopoverRef :: R.Ref (Maybe (Boolean -> Effect Unit)) - , tasks :: T.Box (Maybe GAT.Reductor) + , tasks :: GAT.Reductor | CommonProps ) @@ -101,7 +101,7 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt R.setRef setPopoverRef $ Just $ Popover.setOpen popoverRef let isSelected = Just route' == Routes.nodeTypeAppRoute nodeType (sessionId session) id - tasks' <- T.read tasks + -- tasks' <- T.read tasks pure $ H.span (dropProps droppedFile droppedFile' isDragOver isDragOver') $ reverseHanded handed @@ -117,7 +117,7 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt , onFinish: onTaskFinish id t , session } - ) $ GAT.getTasksMaybe tasks' id + ) $ GAT.getTasks (fst tasks) id ) , if nodeType == GT.NodeUser then GV.versionView {session} @@ -142,10 +142,11 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt ] where onTaskFinish id' t _ = do - mT <- T.read tasks - case mT of - Just t' -> snd t' $ GAT.Finish id' t - Nothing -> pure unit + snd tasks $ GAT.Finish id' t + -- mT <- T.read tasks + -- case mT of + -- Just t' -> snd t' $ GAT.Finish id' t + -- Nothing -> pure unit T2.reload reloadRoot SettingsBox {show: showBox} = settingsBox nodeType diff --git a/src/Gargantext/Components/GraphExplorer.purs b/src/Gargantext/Components/GraphExplorer.purs index 5bdb7f66a9765231daf82848916ada2868662633..2aff31319a09a09e8911efbfd91621359483f1a7 100644 --- a/src/Gargantext/Components/GraphExplorer.purs +++ b/src/Gargantext/Components/GraphExplorer.purs @@ -53,7 +53,7 @@ type BaseProps = , route :: T.Box AppRoute , sessions :: T.Box Sessions , showLogin :: T.Box Boolean - , tasks :: T.Box (Maybe GAT.Reductor) + , tasks :: GAT.Reductor ) type LayoutLoaderProps = ( session :: R.Context Session | BaseProps ) @@ -277,7 +277,7 @@ type TreeProps = ( , sessions :: T.Box Sessions , show :: Boolean , showLogin :: T.Box Boolean - , tasks :: T.Box (Maybe GAT.Reductor) + , tasks :: GAT.Reductor ) type MSidebarProps = diff --git a/src/Gargantext/Components/NgramsTable.purs b/src/Gargantext/Components/NgramsTable.purs index 41895c4e45f4bb76714a862f2624ed190749f29b..b2a342af78a5d56957cbd24256322e2dfd38041f 100644 --- a/src/Gargantext/Components/NgramsTable.purs +++ b/src/Gargantext/Components/NgramsTable.purs @@ -263,7 +263,7 @@ type CommonProps = ( , reloadRoot :: T.Box T2.Reload , sidePanelTriggers :: Record NT.SidePanelTriggers , tabNgramType :: CTabNgramType - , tasks :: T.Box (Maybe GAT.Reductor) + , tasks :: GAT.Reductor , withAutoUpdate :: Boolean ) diff --git a/src/Gargantext/Components/NgramsTable/Core.purs b/src/Gargantext/Components/NgramsTable/Core.purs index 1b2a8e1c1629eeae2333d5912ec25b6230d75a6b..398055d7a6ac91592847501e17895034ce2af429 100644 --- a/src/Gargantext/Components/NgramsTable/Core.purs +++ b/src/Gargantext/Components/NgramsTable/Core.purs @@ -1184,7 +1184,7 @@ chartsAfterSync :: forall props discard. , tabType :: TabType | props } - -> T.Box (Maybe GAT.Reductor) + -> GAT.Reductor -> T.Box T2.Reload -> discard -> Aff Unit @@ -1192,12 +1192,8 @@ chartsAfterSync path'@{ nodeId } tasks reloadForest _ = do task <- postNgramsChartsAsync path' liftEffect $ do log2 "[chartsAfterSync] Synchronize task" task - mT <- T.read tasks - case mT of - Nothing -> log "[chartsAfterSync] tasks is Nothing" - Just tasks' -> do - snd tasks' (GAT.Insert nodeId task) -- *> T2.reload reloadForest - T2.reload reloadForest + snd tasks $ GAT.Insert nodeId task + T2.reload reloadForest postNgramsChartsAsync :: forall s. CoreParams s -> Aff AsyncTaskWithType postNgramsChartsAsync { listIds, nodeId, session, tabType } = do diff --git a/src/Gargantext/Components/Nodes/Annuaire/Tabs.purs b/src/Gargantext/Components/Nodes/Annuaire/Tabs.purs index 84ce51e713daaad5154a965f9be765edea546f2e..8d102217199787dc81931b2411d6a07b0b834c92 100644 --- a/src/Gargantext/Components/Nodes/Annuaire/Tabs.purs +++ b/src/Gargantext/Components/Nodes/Annuaire/Tabs.purs @@ -59,7 +59,7 @@ type TabsProps = , reloadRoot :: T.Box T2.Reload , session :: Session , sidePanelTriggers :: Record LTypes.SidePanelTriggers - , tasks :: T.Box (Maybe GAT.Reductor) + , tasks :: GAT.Reductor ) tabs :: R2.Leaf TabsProps @@ -136,5 +136,5 @@ type NTCommon = , reloadRoot :: T.Box T2.Reload , session :: Session , sidePanelTriggers :: Record LTypes.SidePanelTriggers - , tasks :: T.Box (Maybe GAT.Reductor) + , tasks :: GAT.Reductor ) diff --git a/src/Gargantext/Components/Nodes/Annuaire/User.purs b/src/Gargantext/Components/Nodes/Annuaire/User.purs index 282fed710abc5fb77c3de0c932f3b718b5ef293f..e11a91349b819a4d9dce1c5c6e42dcb3d6d9982b 100644 --- a/src/Gargantext/Components/Nodes/Annuaire/User.purs +++ b/src/Gargantext/Components/Nodes/Annuaire/User.purs @@ -155,7 +155,7 @@ type LayoutNoSessionProps = , nodeId :: Int , reloadForest :: T.Box T2.Reload , reloadRoot :: T.Box T2.Reload - , tasks :: T.Box (Maybe GAT.Reductor) + , tasks :: GAT.Reductor ) type LayoutProps = WithSession LayoutNoSessionProps diff --git a/src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs b/src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs index d704ce1ab54dc2492f47d450e5b10dfe9cfab20a..e1fc341afe50afd5a208954049852008784667ef 100644 --- a/src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs +++ b/src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs @@ -141,7 +141,7 @@ listElement = H.li { className: "list-group-item justify-content-between" } type BasicProps = ( frontends :: Frontends , nodeId :: Int - , tasks :: T.Box (Maybe GAT.Reductor) + , tasks :: GAT.Reductor ) type ReloadProps = diff --git a/src/Gargantext/Components/Nodes/Annuaire/User/Contacts/Tabs.purs b/src/Gargantext/Components/Nodes/Annuaire/User/Contacts/Tabs.purs index eb3e13a70e8554e56df91ac239fdc5f39e52607c..3bd10748a72875b91909e9cf71645428e599652f 100644 --- a/src/Gargantext/Components/Nodes/Annuaire/User/Contacts/Tabs.purs +++ b/src/Gargantext/Components/Nodes/Annuaire/User/Contacts/Tabs.purs @@ -57,7 +57,7 @@ type TabsProps = ( , reloadRoot :: T.Box T2.Reload , session :: Session , sidePanelTriggers :: Record LTypes.SidePanelTriggers - , tasks :: T.Box (Maybe GAT.Reductor) + , tasks :: GAT.Reductor ) tabs :: Record TabsProps -> R.Element @@ -139,7 +139,7 @@ type NgramsViewTabsProps = ( , reloadRoot :: T.Box T2.Reload , session :: Session , sidePanelTriggers :: Record LTypes.SidePanelTriggers - , tasks :: T.Box (Maybe GAT.Reductor) + , tasks :: GAT.Reductor ) ngramsView :: R2.Component NgramsViewTabsProps diff --git a/src/Gargantext/Components/Nodes/Lists.purs b/src/Gargantext/Components/Nodes/Lists.purs index 08af210cd8a8f16817d1fe63326f88b6d6b895a8..924e1ad0bfd77139dc61e53f8c7aff199aee324d 100644 --- a/src/Gargantext/Components/Nodes/Lists.purs +++ b/src/Gargantext/Components/Nodes/Lists.purs @@ -98,7 +98,7 @@ type CommonPropsNoSession = , reloadForest :: T.Box T2.Reload , reloadRoot :: T.Box T2.Reload , sessionUpdate :: Session -> Effect Unit - , tasks :: T.Box (Maybe GAT.Reductor) + , tasks :: GAT.Reductor ) type CommonProps = WithSession CommonPropsNoSession diff --git a/src/Gargantext/Components/Nodes/Lists/Tabs.purs b/src/Gargantext/Components/Nodes/Lists/Tabs.purs index 3189966b96e46ba94e1a6ea4c2240b2e4f59b9b5..69cf451f09f9597e6a440532bcc98d127ed21af1 100644 --- a/src/Gargantext/Components/Nodes/Lists/Tabs.purs +++ b/src/Gargantext/Components/Nodes/Lists/Tabs.purs @@ -41,7 +41,7 @@ type Props = ( , reloadRoot :: T.Box T2.Reload , session :: Session , sidePanelTriggers :: Record SidePanelTriggers - , tasks :: T.Box (Maybe GAT.Reductor) + , tasks :: GAT.Reductor ) type PropsWithKey = ( key :: String | Props ) diff --git a/src/Gargantext/Components/Router.purs b/src/Gargantext/Components/Router.purs index 0475b222e3cc6cfa987685e507a01951d7833b9f..b6c5f8633e1fbd93df666bc1d4ab7aacfa98f09a 100644 --- a/src/Gargantext/Components/Router.purs +++ b/src/Gargantext/Components/Router.purs @@ -42,7 +42,7 @@ import Gargantext.Utils.Reactix as R2 here :: R2.Here here = R2.here "Gargantext.Components.Router" -type Props = ( boxes :: Boxes, tasks :: T.Box (Maybe GAT.Reductor) ) +type Props = ( boxes :: Boxes, tasks :: GAT.Reductor ) type SessionProps = ( session :: R.Context Session, sessionId :: SessionId | Props )