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