Commit f85f4767 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[graph] some refactoring of graph and trying to debug recursion

parent fe8425ea
......@@ -101,7 +101,7 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where
here.log "[drawGraph (Cleanup)] sigma killed"
-- Stage Init
R.useEffect1' graphStage' $ case graphStage' of
R.useEffect2' hyperdataGraph' graphStage' $ case graphStage' of
GET.Init -> do
let mCamera = getter _.mCamera hyperdataGraph'
......
module Gargantext.Components.Nodes.Corpus.Graph
module Gargantext.Components.Nodes.Graph
( node
) where
......@@ -6,7 +6,7 @@ import Gargantext.Prelude
import DOM.Simple (document, querySelector)
import Data.Int as I
import Data.Maybe (Maybe(..), isJust, maybe)
import Data.Maybe (Maybe(..), fromMaybe, isJust, maybe)
import Data.Sequence as Seq
import Data.Tuple (Tuple(..))
import Data.Tuple.Nested ((/\))
......@@ -27,14 +27,16 @@ import Gargantext.Utils (getter)
import Gargantext.Utils.Range as Range
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
import Toestand as T
type Props =
( graphId :: GET.GraphId
)
here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Corpus.Graph"
here = R2.here "Gargantext.Components.Nodes.Graph"
node :: R2.Leaf ( key :: String | Props )
node = R2.leaf nodeCpt
......@@ -49,8 +51,8 @@ nodeCpt = here.component "node" cpt where
session <- useSession
graphVersion' <- R2.useLive' graphVersion
state' /\ state <- R2.useBox' Nothing
cache' /\ cache <- R2.useBox' (GET.defaultCacheParams :: GET.CacheParams)
state <- T.useBox Nothing
cache <- T.useBox (GET.defaultCacheParams :: GET.CacheParams)
-- | Computed
-- |
......@@ -82,8 +84,23 @@ nodeCpt = here.component "node" cpt where
-- | Render
-- |
pure $
pure $ renderNode { cache, graphId, state }
type RenderNodeProps = (
cache :: T.Box GET.CacheParams,
graphId :: GET.GraphId,
state :: T.Box (Maybe GET.HyperdataGraph)
)
renderNode :: R2.Leaf RenderNodeProps
renderNode = R2.leaf renderNodeCpt
renderNodeCpt :: R.Component RenderNodeProps
renderNodeCpt = here.component "renderNode" cpt where
cpt { cache, graphId, state } _ = do
cache' <- T.useLive T.unequal cache
state' <- T.useLive T.unequal state
pure $
B.cloak
{ isDisplayed: isJust state'
, idlingPhaseDuration: Just 150
......@@ -97,6 +114,7 @@ nodeCpt = here.component "node" cpt where
GET.HyperdataGraph { graph: hyperdataGraph } = loaded
Tuple mMetaData graph = convert hyperdataGraph
in
-- H.div {} [ H.text "hello" ]
hydrateStore
{ cacheParams: cache'
, graph
......
......@@ -23,8 +23,8 @@ import Gargantext.Components.Nodes.Corpus as Corpus
import Gargantext.Components.Nodes.Corpus.Code (corpusCodeLayout)
import Gargantext.Components.Nodes.Corpus.Dashboard (dashboardLayout)
import Gargantext.Components.Nodes.Corpus.Document as Document
import Gargantext.Components.Nodes.Corpus.Graph as Graph
import Gargantext.Components.Nodes.Corpus.Phylo as Phylo
import Gargantext.Components.Nodes.Graph as Graph
import Gargantext.Components.Nodes.File (fileLayout)
import Gargantext.Components.Nodes.Frame as Frame
import Gargantext.Components.Nodes.Home (homeLayout)
......
......@@ -78,7 +78,7 @@ useLoaderEffect { errorHandler, loader: loader', path, state } = do
state' <- T.useLive T.unequal state
oPath <- R.useRef path
R.useEffect' $ do
R.useEffect2' path state' $ do
path' <- R.readRefM oPath
if (path' == path) && (isJust state')
then pure $ R.nothing
......
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