Commit 905f19ed authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[toestand] fixed tree state saving

parent 4f0eb144
...@@ -123,7 +123,7 @@ plus handed showLogin backend = H.div { className: "row" } ...@@ -123,7 +123,7 @@ plus handed showLogin backend = H.div { className: "row" }
title = "Add or remove connections to the server(s)." title = "Add or remove connections to the server(s)."
divClass = "fa fa-universal-access" divClass = "fa fa-universal-access"
buttonClass = buttonClass =
"btn btn-primary col-5 " <> switchHanded "ml-1 mr-auto" "mr-1 ml-auto" handed "btn btn-primary col-5 " <> switchHanded "mr-1 ml-auto" "ml-1 mr-auto" handed
forestLayout :: R2.Component Props forestLayout :: R2.Component Props
......
...@@ -141,6 +141,9 @@ explorerCpt = here.component "explorer" cpt ...@@ -141,6 +141,9 @@ explorerCpt = here.component "explorer" cpt
multiSelectEnabledRef <- R.useRef multiSelectEnabled' multiSelectEnabledRef <- R.useRef multiSelectEnabled'
forestOpen <- T.useBox $ Set.empty forestOpen <- T.useBox $ Set.empty
R.useEffectOnce' $ do
R2.loadLocalStorageState R2.openNodesKey forestOpen
T.listen (R2.listenLocalStorageState R2.openNodesKey) forestOpen
R.useEffect' $ do R.useEffect' $ do
let readData = R.readRef dataRef let readData = R.readRef dataRef
......
...@@ -161,23 +161,23 @@ type KeyLayoutProps = ( ...@@ -161,23 +161,23 @@ type KeyLayoutProps = (
| LayoutProps | LayoutProps
) )
userLayout :: Record LayoutProps -> R.Element userLayout :: R2.Component LayoutProps
userLayout props = R.createElement userLayoutCpt props [] userLayout = R.createElement userLayoutCpt
userLayoutCpt :: R.Component LayoutProps userLayoutCpt :: R.Component LayoutProps
userLayoutCpt = here.component "userLayout" cpt userLayoutCpt = here.component "userLayout" cpt
where where
cpt { reloadRoot, tasks, frontends, nodeId, session, reloadForest } _ = do cpt { frontends, nodeId, reloadForest, reloadRoot, session, tasks } _ = do
let sid = sessionId session let sid = sessionId session
pure $ userLayoutWithKey { pure $ userLayoutWithKey {
reloadRoot frontends
, tasks
, frontends
, key: show sid <> "-" <> show nodeId , key: show sid <> "-" <> show nodeId
, nodeId , nodeId
, session
, reloadForest , reloadForest
, reloadRoot
, session
, tasks
} }
userLayoutWithKey :: Record KeyLayoutProps -> R.Element userLayoutWithKey :: Record KeyLayoutProps -> R.Element
......
...@@ -2,6 +2,7 @@ module Gargantext.Components.Router (router) where ...@@ -2,6 +2,7 @@ module Gargantext.Components.Router (router) where
import Data.Array (fromFoldable) import Data.Array (fromFoldable)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import DOM.Simple.Console (log2)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Record as Record import Record as Record
...@@ -113,9 +114,13 @@ forestedCpt = here.component "forested" cpt ...@@ -113,9 +114,13 @@ forestedCpt = here.component "forested" cpt
authed :: Record SessionProps -> R.Element -> R.Element authed :: Record SessionProps -> R.Element -> R.Element
authed props@{ boxes: { sessions }, session, sessionId, tasks } content = authed props@{ boxes: { sessions }, session, sessionId, tasks } content =
sessionWrapper { fallback: home homeProps [], context: session, sessionId, sessions } sessionWrapper { fallback: home homeProps []
[ content, footer { } [] ] , context: session
, render
, sessionId
, sessions } []
where where
render _ = [ content, footer {} [] ]
homeProps = RE.pick props :: Record Props homeProps = RE.pick props :: Record Props
annuaire :: R2.Component SessionNodeProps annuaire :: R2.Component SessionNodeProps
...@@ -343,6 +348,8 @@ userCpt = here.component "user" cpt where ...@@ -343,6 +348,8 @@ userCpt = here.component "user" cpt where
, tasks } _ = do , tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps let sessionProps = RE.pick props :: Record SessionProps
session' <- R.useContext session session' <- R.useContext session
R.useEffect' $ do
log2 "[user] session'" session'
pure $ authed sessionProps $ pure $ authed sessionProps $
forested { boxes, tasks } forested { boxes, tasks }
[ userLayout { frontends [ userLayout { frontends
...@@ -350,7 +357,7 @@ userCpt = here.component "user" cpt where ...@@ -350,7 +357,7 @@ userCpt = here.component "user" cpt where
, reloadForest , reloadForest
, reloadRoot , reloadRoot
, session: session' , session: session'
, tasks } ] , tasks } [] ]
where frontends = defaultFrontends where frontends = defaultFrontends
type ContactProps = ( annuaireId :: NodeID | SessionNodeProps ) type ContactProps = ( annuaireId :: NodeID | SessionNodeProps )
......
...@@ -22,6 +22,7 @@ type Props = ...@@ -22,6 +22,7 @@ type Props =
( (
fallback :: R.Element fallback :: R.Element
, context :: R.Context Session , context :: R.Context Session
, render :: Unit -> Array R.Element
, sessionId :: SessionId , sessionId :: SessionId
, sessions :: T.Box Sessions , sessions :: T.Box Sessions
) )
...@@ -31,10 +32,10 @@ sessionWrapper = R.createElement sessionWrapperCpt ...@@ -31,10 +32,10 @@ sessionWrapper = R.createElement sessionWrapperCpt
sessionWrapperCpt :: R.Component Props sessionWrapperCpt :: R.Component Props
sessionWrapperCpt = here.component "sessionWrapper" cpt where sessionWrapperCpt = here.component "sessionWrapper" cpt where
cpt { fallback, context, sessionId, sessions } content = do cpt { fallback, context, render, sessionId, sessions } _ = do
sessions' <- T.useLive T.unequal sessions sessions' <- T.useLive T.unequal sessions
pure $ cp sessions' pure $ cp sessions'
where where
cp sessions' = c $ Sessions.lookup sessionId sessions' where cp sessions' = c $ Sessions.lookup sessionId sessions' where
c (Just session) = (R.provideContext context session content) c (Just session) = (R.provideContext context session (render unit))
c Nothing = fallback c Nothing = fallback
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