Commit ee654ac1 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[forest] rewrite forest layout so that it won't rerender

parent f8e4fa94
......@@ -76,7 +76,7 @@ forestCpt = here.component "forest" cpt where
handed' <- T.useLive T.unequal handed
reloadForest' <- T.useLive T.unequal reloadForest
-- reloadRoot' <- T.useLive T.unequal reloadRoot
route' <- T.useLive T.unequal route
-- route' <- T.useLive T.unequal route
forestOpen' <- T.useLive T.unequal forestOpen
sessions' <- T.useLive T.unequal sessions
......@@ -85,7 +85,7 @@ forestCpt = here.component "forest" cpt where
-- R.useEffect' $ do
-- R.setRef tasks $ Just tasks'
R2.useCache
( frontends /\ route' /\ sessions' /\ handed' /\ forestOpen' /\ reloadForest' )
( frontends /\ sessions' /\ handed' /\ forestOpen' /\ reloadForest' )
(cp handed' sessions')
where
common = RX.pick props :: Record Common
......
......@@ -30,65 +30,22 @@ import Toestand as T
here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Lists"
type ListsWithForest =
( forestProps :: Record Forest.Props
, listsProps :: Record CommonProps
)
type ListsWithForestSessionContext =
( forestProps :: Record Forest.Props
, listsProps :: Record CommonPropsSessionContext )
listsWithForestSessionContext :: R2.Component ListsWithForestSessionContext
listsWithForestSessionContext = R.createElement listsWithForestSessionContextCpt
listsWithSessionContext :: R2.Component CommonPropsSessionContext
listsWithSessionContext = R.createElement listsWithSessionContextCpt
listsWithForestSessionContextCpt :: R.Component ListsWithForestSessionContext
listsWithForestSessionContextCpt = here.component "listsWithForestSessionContext" cpt where
cpt { forestProps, listsProps: listsProps@{ session } } _ = do
listsWithSessionContextCpt :: R.Component CommonPropsSessionContext
listsWithSessionContextCpt = here.component "listsWithSessionContext" cpt where
cpt props@{ session } _ = do
session' <- R.useContext session
pure $ listsWithForest
{ forestProps
, listsProps: Record.merge { session: session' } $ (REX.pick listsProps :: Record CommonPropsNoSession)
} []
listsWithForest :: R2.Component ListsWithForest
listsWithForest = R.createElement listsWithForestCpt
listsWithForestCpt :: R.Component ListsWithForest
listsWithForestCpt = here.component "listsWithForest" cpt
where
cpt { forestProps
, listsProps: listsProps@{ session } } _ = do
controls <- initialControls
pure $ Forest.forestLayoutWithTopBar forestProps
[ topBar { controls } []
, listsLayout (Record.merge listsProps { controls }) []
-- TODO remove className "side-panel" is preview is not triggered
-- , H.div { className: "" }
, H.div { className: "side-panel" }
[ sidePanel { controls, session } []]
]
pure $ R.fragment [
-- topBar { controls } []
listsLayout (Record.merge { controls, session: session' } props) []
, H.div { className: "side-panel" } [ sidePanel { controls, session: session' } [] ]
]
--------------------------------------------------------
type TopBarProps = ( controls :: Record ListsLayoutControls )
topBar :: R2.Component TopBarProps
topBar = R.createElement topBarCpt
topBarCpt :: R.Component TopBarProps
topBarCpt = here.component "topBar" cpt where
cpt { controls } _ = do
-- empty for now because the button is moved to the side panel
pure $ H.div {} []
-- H.ul { className: "nav navbar-nav" } [
-- H.li {} [
-- sidePanelToggleButton { state: controls.showSidePanel } []
-- ]
-- ] -- head (goes to top bar)
type CommonPropsNoSession =
( nodeId :: Int
, reloadForest :: T.Box T2.Reload
......@@ -110,9 +67,9 @@ listsLayout = R.createElement listsLayoutCpt
listsLayoutCpt :: R.Component Props
listsLayoutCpt = here.component "listsLayout" cpt where
cpt path@{ nodeId, session } _ = do
cpt props@{ nodeId, session } _ = do
let sid = sessionId session
pure $ listsLayoutWithKey $ Record.merge path { key: show sid <> "-" <> show nodeId }
pure $ listsLayoutWithKey $ Record.merge props { key: show sid <> "-" <> show nodeId }
type KeyProps = ( key :: String | Props )
......
......@@ -42,44 +42,21 @@ here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Texts"
--------------------------------------------------------
type TextsWithForest = (
forestProps :: Record Forest.Props
, textsProps :: Record CommonProps
)
type TextsWithForestSessionContext =
( forestProps :: Record Forest.Props
, textsProps :: Record CommonPropsSessionContext )
textsWithForestSessionContext :: R2.Component TextsWithForestSessionContext
textsWithForestSessionContext = R.createElement textsWithForestSessionContextCpt
textsWithSessionContext :: R2.Component CommonPropsSessionContext
textsWithSessionContext = R.createElement textsWithSessionContextCpt
textsWithForestSessionContextCpt :: R.Component TextsWithForestSessionContext
textsWithForestSessionContextCpt = here.component "textsWithForestSessionContext" cpt
textsWithSessionContextCpt :: R.Component CommonPropsSessionContext
textsWithSessionContextCpt = here.component "textsWithSessionContext" cpt
where
cpt { forestProps, textsProps: textsProps@{ session } } _ = do
cpt props@{ session } _ = do
session' <- R.useContext session
pure $ textsWithForest
{ forestProps
, textsProps: Record.merge { session: session' } $ (REX.pick textsProps :: Record CommonPropsNoSession)
} []
textsWithForest :: R2.Component TextsWithForest
textsWithForest = R.createElement textsWithForestCpt
textsWithForestCpt :: R.Component TextsWithForest
textsWithForestCpt = here.component "textsWithForest" cpt
where
cpt { forestProps, textsProps: textProps@{ session } } _ = do
controls <- initialControls
pure $ Forest.forestLayoutWithTopBar forestProps
[ topBar { controls } []
, textsLayout (Record.merge textProps { controls }) []
-- TODO remove className "side-panel" is preview is not triggered
-- , H.div { className: "" }
, H.div { className: "side-panel" }
[ sidePanel { controls, session } [] ]]
pure $ R.fragment
[ -- topBar { controls } []
textsLayout (Record.merge { controls, session: session' } props) []
, H.div { className: "side-panel" } [ sidePanel { controls, session: session' } [] ]
]
type TopBarProps = ( controls :: Record TextsLayoutControls )
......
This diff is collapsed.
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