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