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
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Grégoire Locqueville
purescript-gargantext
Commits
06a87aa3
Commit
06a87aa3
authored
Jan 25, 2020
by
Justin Woo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix constant remounting of the tree view
parent
33bb55e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
14 deletions
+21
-14
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+21
-14
No files found.
src/Gargantext/Components/Forest/Tree.purs
View file @
06a87aa3
...
@@ -41,36 +41,43 @@ treeViewCpt = R.hooksComponent "G.C.Tree.treeView" cpt
...
@@ -41,36 +41,43 @@ treeViewCpt = R.hooksComponent "G.C.Tree.treeView" cpt
-- NOTE: this is a hack to reload the tree view on demand
-- NOTE: this is a hack to reload the tree view on demand
reload <- R.useState' (0 :: Reload)
reload <- R.useState' (0 :: Reload)
openNodes <- R2.useLocalStorageState R2.openNodesKey (Set.empty :: Set TreeId)
openNodes <- R2.useLocalStorageState R2.openNodesKey (Set.empty :: Set TreeId)
pure $ treeLoadView
reload
pure $ treeLoadView
{ root, mCurrentRoute, session, frontends, openNodes }
{ root, mCurrentRoute, session, frontends, openNodes
, reload
}
type Props' = ( root :: ID
type Props' = ( root :: ID
, mCurrentRoute :: Maybe AppRoute
, mCurrentRoute :: Maybe AppRoute
, session :: Session
, session :: Session
, frontends :: Frontends
, frontends :: Frontends
, openNodes :: R.State (Set TreeId)
, openNodes :: R.State (Set TreeId)
, reload :: R.State Reload
)
)
treeLoadView :: R.State Reload -> Record Props' -> R.Element
treeLoadView :: Record Props' -> R.Element
treeLoadView reload p = R.createElement el p []
treeLoadView p = R.createElement treeLoadView' p []
treeLoadView' :: R.Component Props'
treeLoadView' = R.staticComponent "TreeLoadView" cpt
where
where
el = R.staticComponent "TreeLoadView" cpt
cpt {root, mCurrentRoute, session, frontends, openNodes, reload} _ = do
cpt {root, mCurrentRoute, session, frontends, openNodes} _ = do
loader root (loadNode session) $ \loaded ->
loader root (loadNode session) $ \loaded ->
loadedTreeView
reload {tree: loaded, mCurrentRoute, session, frontends, openNodes
}
loadedTreeView
{tree: loaded, mCurrentRoute, session, frontends, openNodes, reload
}
type TreeViewProps = ( tree :: FTree
type TreeViewProps = ( tree :: FTree
, mCurrentRoute :: Maybe AppRoute
, mCurrentRoute :: Maybe AppRoute
, frontends :: Frontends
, frontends :: Frontends
, session :: Session
, session :: Session
, openNodes :: R.State (Set TreeId)
, openNodes :: R.State (Set TreeId)
, reload :: R.State Reload
)
)
loadedTreeView :: R.State Reload -> Record TreeViewProps -> R.Element
loadedTreeView reload p = R.createElement el p []
loadedTreeView :: Record TreeViewProps -> R.Element
loadedTreeView p = R.createElement loadedTreeView' p []
loadedTreeView' :: R.Component TreeViewProps
loadedTreeView' = R.hooksComponent "LoadedTreeView" cpt
where
where
el = R.hooksComponent "LoadedTreeView" cpt
cpt {tree, mCurrentRoute, session, frontends, openNodes, reload} _ = do
cpt {tree, mCurrentRoute, session, frontends, openNodes} _ = do
treeState <- R.useState' {tree, asyncTasks: []}
treeState <- R.useState' {tree, asyncTasks: []}
pure $ H.div {className: "tree"}
pure $ H.div {className: "tree"}
...
@@ -110,9 +117,9 @@ toHtml reload treeState@(ts@{tree: (NTree (LNode {id, name, nodeType}) ary), asy
...
@@ -110,9 +117,9 @@ toHtml reload treeState@(ts@{tree: (NTree (LNode {id, name, nodeType}) ary), asy
)
)
]
]
onAsyncTaskFinish (AsyncTask {id}) = setTreeState $ const $ ts { asyncTasks = newAsyncTasks }
onAsyncTaskFinish (AsyncTask {id
: id_
}) = setTreeState $ const $ ts { asyncTasks = newAsyncTasks }
where
where
newAsyncTasks = A.filter (\(AsyncTask {id: id'}) -> id /= id') asyncTasks
newAsyncTasks = A.filter (\(AsyncTask {id: id'}) -> id
_
/= id') asyncTasks
childNodes :: Session
childNodes :: Session
...
...
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