[Tree] preparatory refactorings

* The tree state is now a record (required later)
* API calls are made using Config.REST functions
* loadDefaultNode is now loadNode which takes the root ID
parent 4b2e6002
This diff is collapsed.
...@@ -6,8 +6,9 @@ import Control.Monad.Cont.Trans (lift) ...@@ -6,8 +6,9 @@ import Control.Monad.Cont.Trans (lift)
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Lens (Prism', prism) import Data.Lens (Prism', prism)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Thermite (PerformAction, modifyState) import Thermite (PerformAction, modifyState, modifyState_)
import Gargantext.Config (defaultRoot)
import Gargantext.Components.Login as LN import Gargantext.Components.Login as LN
import Gargantext.Components.Modals.Modal (modalShow) import Gargantext.Components.Modals.Modal (modalShow)
import Gargantext.Components.Tree as Tree import Gargantext.Components.Tree as Tree
...@@ -67,18 +68,13 @@ performAction Go _ _ = void do ...@@ -67,18 +68,13 @@ performAction Go _ _ = void do
--modifyState id --modifyState id
--------------------------------------------------------- ---------------------------------------------------------
performAction Initialize _ state = void do performAction Initialize _ state = do
_ <- logs "loading Initial nodes" _ <- logs "loading Initial nodes"
case state.initialized of case state.initialized of
false -> do false -> do
lnodes <- lift $ Tree.loadDefaultNode d <- lift $ Tree.loadNode defaultRoot
case lnodes of modifyState_ $ _ { initialized = true, ntreeState = {state: d} }
Left err -> do _ -> pure unit
modifyState identity
Right d -> do
modifyState $ _ { initialized = true, ntreeState = d }
_ -> do
modifyState identity
performAction (LoginA _) _ _ = pure unit performAction (LoginA _) _ _ = pure unit
performAction (AddCorpusA _) _ _ = pure unit performAction (AddCorpusA _) _ _ = pure unit
......
...@@ -38,7 +38,7 @@ initAppState = ...@@ -38,7 +38,7 @@ initAppState =
, searchState : S.initialState , searchState : S.initialState
, userPageState : C.initialState , userPageState : C.initialState
, documentState : D.initialState {} , documentState : D.initialState {}
, ntreeState : Tree.exampleTree , ntreeState : {state: Tree.exampleTree}
, search : "" , search : ""
, showLogin : false , showLogin : false
, showCorpus : false , showCorpus : false
......
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