Commit 3b6e5e7b authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[Graph] more careful usage of cleanup code

Now state change doesn't refresh the graph.
parent 9ad149cf
......@@ -9,6 +9,7 @@ import Data.Maybe (Maybe)
import Data.Nullable (null)
import Data.Sequence as Seq
import DOM.Simple.Console (log, log2)
import FFI.Simple (delay)
import Reactix as R
import Reactix.DOM.HTML as RH
......@@ -47,10 +48,14 @@ graphCpt = R.hooksComponent "Graph" cpt
ref <- R.useRef null
--startSigma ref props.sigmaRef props.sigmaSettings props.forceAtlas2Settings props.graph
R.useEffectOnce' $ do
R.useEffectOnce $ do
log "[graphCpt] calling startSigmaEff"
startSigmaEff ref props.sigmaRef props.sigmaSettings props.forceAtlas2Settings props.graph
delay unit $ \_ -> do
log "[GraphCpt] cleaning up"
pure $ pure unit
pure $ RH.div { ref, style: {height: "95%"} } []
type SigmaSettings =
......
......@@ -220,15 +220,25 @@ dependOnContainer container notFoundMsg f = do
startSigmaEff :: forall settings faSettings n e. R.Ref (Nullable Element) -> R.Ref Sigma -> settings -> faSettings -> Graph n e -> Effect Unit
startSigmaEff ref sigmaRef settings forceAtlas2Settings graph = do
log "[startSigmaEff] calling useSigmaEff"
sigma <- useSigmaEff settings sigmaRef
log "[startSigmaEff] calling useCanvasRendererEff"
useCanvasRendererEff ref sigma
log "[startSigmaEff] calling useDataEff"
useDataEff sigma graph
log "[startSigmaEff] calling useForceAtlas2Eff"
useForceAtlas2Eff sigma forceAtlas2Settings
let rSigma = R.readRef sigmaRef
case readSigma rSigma of
Nothing -> do
log "[startSigmaEff] calling useSigmaEff"
sigma <- useSigmaEff settings sigmaRef
log "[startSigmaEff] calling useCanvasRendererEff"
useCanvasRendererEff ref sigma
log "[startSigmaEff] calling useDataEff"
useDataEff sigma graph
log "[startSigmaEff] calling useForceAtlas2Eff"
useForceAtlas2Eff sigma forceAtlas2Settings
Just sig -> do
log "[startSigmaEff] sigma initialized already"
useCanvasRendererEff ref rSigma
useDataEff rSigma graph
--useForceAtlas2Eff rSigma forceAtlas2Settings
Sigma.refreshForceAtlas sig
pure unit
--handleRefresh sigma
......@@ -275,9 +285,10 @@ useCanvasRendererEff container sigma =
withSigma sig = addRenderer sig renderer >>= handle
where -- close over sig
renderer = { "type": "canvas", container: c }
handle (Right _) = cleanupFirst sigma (Sigma.killRenderer sig renderer >>= logCleanup)
handle (Left e) =
log2 errorAddingMsg e *> cleanupSigma sigma "useCanvasRenderer"
handle _ = log "[useCanvasRenderer] cleanup handle"
--handle (Right _) = cleanupFirst sigma (Sigma.killRenderer sig renderer >>= logCleanup)
--handle (Left e) =
-- log2 errorAddingMsg e *> cleanupSigma sigma "useCanvasRenderer"
logCleanup (Left e) = log2 errorKillingMsg e
logCleanup _ = log killedMsg
containerNotFoundMsg = "[useCanvasRenderer] Container not found, not adding renderer"
......@@ -294,6 +305,6 @@ useForceAtlas2Eff sigma settings = effect
log startingMsg
log sigma
Sigma.startForceAtlas2 sig settings
cleanupFirst sigma (Sigma.killForceAtlas2 sig)
--cleanupFirst sigma (Sigma.killForceAtlas2 sig)
startingMsg = "[Graph] Starting ForceAtlas2"
sigmaNotFoundMsg = "[Graph] Sigma not found, not initialising"
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