Commit c6497f31 authored by arturo's avatar arturo

[subtree] Fold subtree node by default

* #308 (2): resolve re-render issue
parent e4531010
Pipeline #1800 failed with stage
module Gargantext.Components.Forest.Tree.Node.Action.Move where module Gargantext.Components.Forest.Tree.Node.Action.Move
( moveNodeReq
, moveNode
) where
import Data.Either (Either) import Data.Either (Either)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..)) import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..))
import Gargantext.Components.Forest.Tree.Node.Tools (submitButton, panel) import Gargantext.Components.Forest.Tree.Node.Tools (submitButton, panel)
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (subTreeView, SubTreeParamsIn) import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (SubTreeParamsIn, subTreeView)
import Gargantext.Config.REST (RESTError) import Gargantext.Config.REST (RESTError)
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(..)) import Gargantext.Routes (SessionRoute(..))
...@@ -30,6 +33,30 @@ moveNodeCpt = here.component "moveNode" cpt ...@@ -30,6 +33,30 @@ moveNodeCpt = here.component "moveNode" cpt
where where
cpt { boxes, dispatch, id, nodeType, session, subTreeParams } _ = do cpt { boxes, dispatch, id, nodeType, session, subTreeParams } _ = do
action :: T.Box Action <- T.useBox (MoveNode {params: Nothing}) action :: T.Box Action <- T.useBox (MoveNode {params: Nothing})
pure $
moveNode' { action
, boxes
, dispatch
, id
, nodeType
, session
, subTreeParams
} []
type Props =
( action :: T.Box Action
| SubTreeParamsIn
)
-- @XXX re-render issue -> clone component
moveNode' :: R2.Component Props
moveNode' = R.createElement moveNodeCpt'
moveNodeCpt' :: R.Component Props
moveNodeCpt' = here.component "foo" cpt where
cpt { boxes, dispatch, id, nodeType, session, subTreeParams, action } _ = do
action' <- T.useLive T.unequal action action' <- T.useLive T.unequal action
let button = case action' of let button = case action' of
...@@ -40,7 +67,8 @@ moveNodeCpt = here.component "moveNode" cpt ...@@ -40,7 +67,8 @@ moveNodeCpt = here.component "moveNode" cpt
pure $ pure $
panel [ subTreeView { action panel
[ subTreeView { action
, boxes , boxes
, dispatch , dispatch
, id , id
......
...@@ -44,7 +44,7 @@ type SubTreeParamsProps = ...@@ -44,7 +44,7 @@ type SubTreeParamsProps =
) )
subTreeView :: R2.Component SubTreeParamsProps subTreeView :: R2.Component SubTreeParamsProps
subTreeView = R.createElement subTreeViewCpt subTreeView = R.createElement $ R.memo' subTreeViewCpt
subTreeViewCpt :: R.Component SubTreeParamsProps subTreeViewCpt :: R.Component SubTreeParamsProps
subTreeViewCpt = here.component "subTreeView" cpt subTreeViewCpt = here.component "subTreeView" cpt
where where
......
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