Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-gargantext
Commits
3c163dc8
Unverified
Commit
3c163dc8
authored
Jul 02, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Loader2] working
parent
bb8227db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
17 deletions
+24
-17
Loader2.purs
src/Gargantext/Components/Loader2.purs
+16
-12
Tree.purs
src/Gargantext/Components/Tree.purs
+8
-5
No files found.
src/Gargantext/Components/Loader2.purs
View file @
3c163dc8
module Gargantext.Components.Loader2 where
module Gargantext.Components.Loader2 where
--import Control.Monad.Cont.Trans (lift)
import Data.Maybe (Maybe(..), isNothing)
import Data.Maybe (Maybe(..), isNothing)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Gargantext.Prelude
import Gargantext.Prelude
import Effect (Effect)
import Effect.Aff (Aff, launchAff, launchAff_, killFiber)
--import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Effect.Exception (error)
import Reactix as R
import Reactix as R
type State path loaded = { currentPath :: path, loaded :: Maybe loaded }
type State path loaded = { currentPath :: path, loaded :: Maybe loaded }
...
@@ -15,22 +15,26 @@ useLoader
...
@@ -15,22 +15,26 @@ useLoader
. Eq path
. Eq path
=> Show path
=> Show path
=> path
=> path
-> (path ->
Effect
loaded)
-> (path ->
Aff
loaded)
-> (path -> loaded ->
Array
R.Element)
-> (path -> loaded -> R.Element)
-> R.Hooks
(Array R.Element)
-> R.Hooks
R.Element
useLoader newPath loader render = do
useLoader newPath loader render = do
{currentPath, loaded} /\ setState <- R.useState' { currentPath: newPath, loaded: Nothing }
{currentPath, loaded} /\ setState <- R.useState' { currentPath: newPath, loaded: Nothing }
-- What about cleanup handlers?
R.useEffect $ \_ ->
R.useEffect' $ \_ ->
if (isNothing loaded || newPath /= currentPath) then do
when (isNothing loaded || newPath /= currentPath) do
logs $ "useLoader " <> show {newPath, currentPath, loadedIsNothing: isNothing loaded}
logs $ "useLoader " <> show {newPath, currentPath, loadedIsNothing: isNothing loaded}
freshlyLoaded <- loader newPath
setState { currentPath: newPath, loaded: Just freshlyLoaded }
fiber <- launchAff do
freshlyLoaded <- loader newPath
liftEffect $ setState { currentPath: newPath, loaded: Just freshlyLoaded }
pure $ \_ -> launchAff_ $ killFiber (error "useLoader") fiber
else do
pure $ \_ -> pure unit
pure case loaded of
pure case loaded of
Nothing ->
Nothing ->
-- TODO load spinner
-- TODO load spinner
[]
R.fragment
[]
Just loadedData ->
Just loadedData ->
render currentPath loadedData
render currentPath loadedData
src/Gargantext/Components/Tree.purs
View file @
3c163dc8
...
@@ -229,10 +229,12 @@ treeview :: Spec {} Props Void
...
@@ -229,10 +229,12 @@ treeview :: Spec {} Props Void
treeview = simpleSpec defaultPerformAction render
treeview = simpleSpec defaultPerformAction render
where
where
render :: Render {} Props Void
render :: Render {} Props Void
render _ {root} _ _ =
render _ props _ _ = [R2.scuff $ R.createElement cpt props []]
R.hooksComponent "TreeView" \props children ->
cpt =
R.hooksComponent "TreeView" \{root} _children ->
useLoader root loadNode \currentPath loaded ->
useLoader root loadNode \currentPath loaded ->
R
eact.createElement treeViewClass {tree: loaded}
R
2.buff $ React.createElement treeViewClass {tree: loaded} []
--nodePopupView :: forall s. (Action -> Effect Unit) -> FTree -> RAction s -> R.Element
--nodePopupView :: forall s. (Action -> Effect Unit) -> FTree -> RAction s -> R.Element
...
@@ -588,8 +590,9 @@ fldr :: Boolean -> String
...
@@ -588,8 +590,9 @@ fldr :: Boolean -> String
fldr open = if open then "fas fa-folder-open" else "fas fa-folder"
fldr open = if open then "fas fa-folder-open" else "fas fa-folder"
loadNode :: ID -> Effect FTree
loadNode :: ID -> Aff FTree
loadNode a = lift ((get <<< toUrl Back Tree <<< Just) a)
-- loadNode a = lift ((get <<< toUrl Back Tree <<< Just) a)
loadNode = get <<< toUrl Back Tree <<< Just
----- TREE CRUD Operations
----- TREE CRUD Operations
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment