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