Commit 65165d69 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[Graph] default 2-sec timeout for forceAtlas2

parent ecf2265f
......@@ -14,6 +14,7 @@ import Data.Sequence (Seq)
import Data.Sequence as Seq
import Data.Traversable (traverse_)
import Effect (Effect)
import Effect.Timer (setTimeout)
import FFI.Simple (delay)
import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Hooks.Sigmax.Types (Graph(..))
......@@ -27,6 +28,8 @@ type Sigma =
, cleanup :: R.Ref (Seq (Effect Unit))
}
type ForceAtlas2Timeout = Int
type Data n e = { graph :: R.Ref (Graph n e) }
initSigma :: R.Hooks Sigma
......@@ -231,7 +234,7 @@ startSigmaEff ref sigmaRef settings forceAtlas2Settings graph = do
log "[startSigmaEff] calling useDataEff"
useDataEff sigma graph
log "[startSigmaEff] calling useForceAtlas2Eff"
useForceAtlas2Eff sigma forceAtlas2Settings
useForceAtlas2Eff sigma forceAtlas2Settings (Just 2000)
Just sig -> do
log "[startSigmaEff] sigma initialized already"
useCanvasRendererEff ref rSigma
......@@ -297,8 +300,8 @@ useCanvasRendererEff container sigma =
errorKillingMsg = "[useCanvasRenderer] Error killing renderer:"
killedMsg = "[useCanvasRenderer] Killed renderer"
useForceAtlas2Eff :: forall settings. Sigma -> settings -> Effect Unit
useForceAtlas2Eff sigma settings = effect
useForceAtlas2Eff :: forall settings. Sigma -> settings -> Maybe ForceAtlas2Timeout -> Effect Unit
useForceAtlas2Eff sigma settings mFATimeout = effect
where
effect = dependOnSigma sigma sigmaNotFoundMsg withSigma
withSigma sig = do
......@@ -306,5 +309,11 @@ useForceAtlas2Eff sigma settings = effect
log sigma
Sigma.startForceAtlas2 sig settings
--cleanupFirst sigma (Sigma.killForceAtlas2 sig)
case mFATimeout of
Nothing -> pure unit
Just timeout -> do
_ <- setTimeout timeout $ do
Sigma.stopForceAtlas2 sig
pure unit
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