Commit 683f495e authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'feature/toestand-global-state' of...

Merge branch 'feature/toestand-global-state' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev-merge
parents dcc61ff7 ebb67a01
...@@ -13,10 +13,10 @@ import Gargantext.Utils.Toestand as T2 ...@@ -13,10 +13,10 @@ import Gargantext.Utils.Toestand as T2
type App = type App =
{ backend :: Maybe Backend { backend :: Maybe Backend
, handed :: Handed
, forestOpen :: OpenNodes , forestOpen :: OpenNodes
, reloadRoot :: Int , handed :: Handed
, reloadForest :: Int , reloadForest :: Int
, reloadRoot :: Int
, route :: AppRoute , route :: AppRoute
, sessions :: Sessions , sessions :: Sessions
, showCorpus :: Boolean , showCorpus :: Boolean
...@@ -26,11 +26,11 @@ type App = ...@@ -26,11 +26,11 @@ type App =
emptyApp :: App emptyApp :: App
emptyApp = emptyApp =
{ backend: Nothing { backend: Nothing
, handed: RightHanded
, route: Home
, forestOpen: Set.empty , forestOpen: Set.empty
, reloadRoot: T2.newReload , handed: RightHanded
, reloadForest: T2.newReload , reloadForest: T2.newReload
, reloadRoot: T2.newReload
, route: Home
, sessions: Sessions.empty , sessions: Sessions.empty
, showCorpus: false , showCorpus: false
, showLogin: false , showLogin: false
...@@ -38,10 +38,10 @@ emptyApp = ...@@ -38,10 +38,10 @@ emptyApp =
type Boxes = type Boxes =
{ backend :: T.Box (Maybe Backend) { backend :: T.Box (Maybe Backend)
, handed :: T.Box Handed
, forestOpen :: T.Box OpenNodes , forestOpen :: T.Box OpenNodes
, reloadRoot :: T.Box T2.Reload , handed :: T.Box Handed
, reloadForest :: T.Box T2.Reload , reloadForest :: T.Box T2.Reload
, reloadRoot :: T.Box T2.Reload
, route :: T.Box AppRoute , route :: T.Box AppRoute
, sessions :: T.Box Sessions , sessions :: T.Box Sessions
, showCorpus :: T.Box Boolean , showCorpus :: T.Box Boolean
......
...@@ -73,10 +73,12 @@ treeLoader = R.createElement treeLoaderCpt ...@@ -73,10 +73,12 @@ treeLoader = R.createElement treeLoaderCpt
treeLoaderCpt :: R.Component LoaderProps treeLoaderCpt :: R.Component LoaderProps
treeLoaderCpt = here.component "treeLoader" cpt where treeLoaderCpt = here.component "treeLoader" cpt where
-- treeLoaderCpt :: R.Memo LoaderProps
-- treeLoaderCpt = R.memo (here.component "treeLoader" cpt) memoCmp where
-- memoCmp ({ root: t1 }) ({ root: t2 }) = t1 == t2
cpt p@{ root, session } _ = do cpt p@{ root, session } _ = do
app <- T.useLive T.unequal p.reloadRoot app <- T.useLive T.unequal p.reloadRoot
reload <- T.useLive T.unequal p.reload let fetch { root: r } = getNodeTree session r
let fetch _ = getNodeTree session root
useLoader { app, root } fetch loaded where useLoader { app, root } fetch loaded where
loaded tree' = tree props where loaded tree' = tree props where
props = Record.merge common extra where props = Record.merge common extra where
......
...@@ -58,8 +58,10 @@ routerCpt = here.component "router" cpt where ...@@ -58,8 +58,10 @@ routerCpt = here.component "router" cpt where
let session = R.createContext (unsafeCoerce {}) let session = R.createContext (unsafeCoerce {})
let sessionProps sId = Record.merge { session, sessionId: sId } props let sessionProps sId = Record.merge { session, sessionId: sId } props
let sessionNodeProps sId nId = Record.merge { nodeId: nId } $ sessionProps sId let sessionNodeProps sId nId = Record.merge { nodeId: nId } $ sessionProps sId
showLogin <- T.useLive T.unequal boxes.showLogin showLogin <- T.useLive T.unequal boxes.showLogin
route' <- T.useLive T.unequal boxes.route route' <- T.useLive T.unequal boxes.route
pure $ R.fragment pure $ R.fragment
[ if showLogin then login' boxes else H.div {} [] [ if showLogin then login' boxes else H.div {} []
, case route' of , case route' of
......
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