Commit 1ddc6d3d authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[toestand] fix tasks, sessions loading

parent efb26a3d
module Gargantext.Components.App (app) where
import Data.Maybe (Maybe(..))
import Prelude
import Reactix as R
import Toestand as T
import Gargantext.Prelude
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.App.Data (emptyApp)
import Gargantext.Components.Router (router)
import Gargantext.Hooks (useHashRouter)
import Gargantext.Router as Router
import Gargantext.Sessions as Sessions
import Gargantext.Utils.Reactix as R2
here :: R2.Here
......@@ -22,6 +25,11 @@ 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
tasks <- T.useBox Nothing -- storage for asynchronous tasks reductor
R.useEffect' $ do
void $ Sessions.load boxes.sessions
tasksReductor <- GAT.useTasks boxes.reloadRoot boxes.reloadForest
R.useEffect' $ do
T.write (Just tasksReductor) tasks
useHashRouter Router.router boxes.route -- Install router to window
pure $ router { boxes, tasks } -- Render router component
......@@ -3,6 +3,7 @@ module Gargantext.Components.Router (router) where
import Data.Array (fromFoldable)
import Data.Maybe (Maybe(..))
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
import Record.Extra as RE
import Toestand as T
......@@ -59,8 +60,9 @@ routerCpt = here.component "router" cpt where
let sessionNodeProps sId nId = Record.merge { nodeId: nId } $ sessionProps sId
showLogin <- T.useLive T.unequal boxes.showLogin
route' <- T.useLive T.unequal boxes.route
pure $ if showLogin then login' boxes
else case route' of
pure $ R.fragment
[ if showLogin then login' boxes else H.div {} []
, case route' of
GR.Annuaire s n -> annuaire (sessionNodeProps s n) []
GR.ContactPage s a n -> contact (Record.merge { annuaireId: a } $ sessionNodeProps s n) []
GR.Corpus s n -> corpus (sessionNodeProps s n) []
......@@ -82,6 +84,7 @@ routerCpt = here.component "router" cpt where
GR.Team s n -> team (sessionNodeProps s n) []
GR.Texts s n -> texts (sessionNodeProps s n) []
GR.UserPage s n -> user (sessionNodeProps s n) []
]
forested :: R2.Component Props
forested = R.createElement forestedCpt
......
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