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
d5c430c4
Commit
d5c430c4
authored
Mar 26, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[toestand] refactor tasks to be pure Reductor
No Box needed.
parent
d44d9447
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
52 additions
and
62 deletions
+52
-62
App.purs
src/Gargantext/Components/App.purs
+4
-4
Forest.purs
src/Gargantext/Components/Forest.purs
+18
-14
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+6
-17
Node.purs
src/Gargantext/Components/Forest/Tree/Node.purs
+9
-8
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+2
-2
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+1
-1
Core.purs
src/Gargantext/Components/NgramsTable/Core.purs
+3
-7
Tabs.purs
src/Gargantext/Components/Nodes/Annuaire/Tabs.purs
+2
-2
User.purs
src/Gargantext/Components/Nodes/Annuaire/User.purs
+1
-1
Contact.purs
src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs
+1
-1
Tabs.purs
...gantext/Components/Nodes/Annuaire/User/Contacts/Tabs.purs
+2
-2
Lists.purs
src/Gargantext/Components/Nodes/Lists.purs
+1
-1
Tabs.purs
src/Gargantext/Components/Nodes/Lists/Tabs.purs
+1
-1
Router.purs
src/Gargantext/Components/Router.purs
+1
-1
No files found.
src/Gargantext/Components/App.purs
View file @
d5c430c4
...
...
@@ -25,12 +25,12 @@ appCpt = here.component "app" cpt where
cpt _ _ = do
box <- T.useBox emptyApp -- global data
boxes <- T.useFocusedFields box {} -- read-write access for children
tasks <- T.useBox Nothing -- storage for asynchronous tasks reductor
--
tasks <- T.useBox Nothing -- storage for asynchronous tasks reductor
R.useEffectOnce' $ do
void $ Sessions.load boxes.sessions
tasks
Reductor
<- GAT.useTasks boxes.reloadRoot boxes.reloadForest
R.useEffectOnce' $ do
T.write (Just tasksReductor) tasks
tasks <- GAT.useTasks boxes.reloadRoot boxes.reloadForest
--
R.useEffectOnce' $ do
--
T.write (Just tasksReductor) tasks
R.useEffectOnce' $ do
R2.loadLocalStorageState R2.openNodesKey boxes.forestOpen
T.listen (R2.listenLocalStorageState R2.openNodesKey) boxes.forestOpen
...
...
src/Gargantext/Components/Forest.purs
View file @
d5c430c4
...
...
@@ -33,11 +33,12 @@ here = R2.here "Gargantext.Components.Forest"
-- Shared by components here with Tree
type Common =
( frontends :: Frontends
, handed :: T.Box Handed
, reloadRoot :: T.Box T2.Reload
, route :: T.Box AppRoute
, tasks :: T.Box (Maybe GAT.Reductor)
( frontends :: Frontends
, handed :: T.Box Handed
, reloadRoot :: T.Box T2.Reload
, route :: T.Box AppRoute
-- , tasks :: T.Box (Maybe GAT.Reductor)
, tasks :: GAT.Reductor
)
type Props =
...
...
@@ -69,29 +70,32 @@ forestCpt = here.component "forest" cpt where
, sessions
, showLogin
, tasks } _ = do
tasks' <- GAT.useTasks reloadRoot reloadForest
R.useEffect' $ T.write_ (Just tasks') tasks
-- TODO Fix this. I think tasks shouldn't be a Box but only a Reductor
-- tasks' <- GAT.useTasks reloadRoot reloadForest
-- R.useEffect' $ do
-- T.write_ (Just tasks') tasks
handed' <- T.useLive T.unequal handed
reloadForest' <- T.useLive T.unequal reloadForest
reloadRoot' <- T.useLive T.unequal reloadRoot
route' <- T.useLive T.unequal route
forestOpen' <- T.useLive T.unequal forestOpen
sessions' <- T.useLive T.unequal sessions
-- TODO If `reloadForest` is set, `reload` state should be updated
-- TODO fix tasks ref
-- R.useEffect' $ do
-- R.setRef tasks $ Just tasks'
R2.useCache
( frontends /\ route' /\ sessions' /\ handed' /\ forestOpen'
/\ reloadForest' /\ reloadRoot' /\ (fst tasks
'
).storage )
(cp handed' sessions'
tasks'
)
/\ reloadForest' /\ reloadRoot' /\ (fst tasks).storage )
(cp handed' sessions')
where
common = RX.pick props :: Record Common
cp handed' sessions'
tasks'
_ =
cp handed' sessions' _ =
pure $ H.div { className: "forest" }
(A.cons (plus handed' showLogin backend) (trees handed' sessions'
tasks'
))
trees handed' sessions'
tasks' = (tree handed' tasks
') <$> unSessions sessions'
tree handed'
tasks'
s@(Session {treeId}) =
(A.cons (plus handed' showLogin backend) (trees handed' sessions'))
trees handed' sessions'
= (tree handed
') <$> unSessions sessions'
tree handed' s@(Session {treeId}) =
treeLoader { forestOpen
, frontends
, handed: handed'
...
...
@@ -193,7 +197,7 @@ mainPage = R.createElement mainPageCpt
-- mainPageCpt :: R.Memo ()
-- mainPageCpt = R.memo (here.component "mainPage" cpt) where
mainPageCpt :: R.Component()
mainPageCpt :: R.Component
()
mainPageCpt = here.component "mainPage" cpt
where
cpt _ children = do
...
...
src/Gargantext/Components/Forest/Tree.purs
View file @
d5c430c4
...
...
@@ -48,7 +48,8 @@ here = R2.here "Gargantext.Components.Forest.Tree"
-- Shared by every component here + performAction + nodeSpan
type Universal =
( reloadRoot :: T.Box T2.Reload
, tasks :: T.Box (Maybe GAT.Reductor) )
-- , tasks :: T.Box (Maybe GAT.Reductor) )
, tasks :: GAT.Reductor )
-- Shared by every component here + nodeSpan
type Global =
...
...
@@ -178,19 +179,13 @@ performAction (DeleteNode nt) p@{ forestOpen
performAction RefreshTree p
performAction (DoSearch task) p@{ tasks
, tree: (NTree (LNode {id}) _) } = liftEffect $ do
mT <- T.read tasks
case mT of
Just t -> snd t $ GAT.Insert id task
Nothing -> pure unit
snd tasks $ GAT.Insert id task
log2 "[performAction] DoSearch task:" task
performAction (UpdateNode params) p@{ tasks
, tree: (NTree (LNode {id}) _) } = do
task <- updateRequest params p.session id
liftEffect $ do
mT <- T.read tasks
case mT of
Just t -> snd t $ GAT.Insert id task
Nothing -> pure unit
snd tasks $ GAT.Insert id task
log2 "[performAction] UpdateNode task:" task
performAction (RenameNode name) p@{ tree: (NTree (LNode {id}) _) } = do
void $ rename p.session id $ RenameValue { text: name }
...
...
@@ -213,19 +208,13 @@ performAction (UploadFile nodeType fileType mName blob) p@{ tasks
, tree: (NTree (LNode { id }) _) } = do
task <- uploadFile p.session nodeType id fileType {mName, blob}
liftEffect $ do
mT <- T.read tasks
case mT of
Just t -> snd t $ GAT.Insert id task
Nothing -> pure unit
snd tasks $ GAT.Insert id task
log2 "[performAction] UploadFile, uploaded, task:" task
performAction (UploadArbitraryFile mName blob) p@{ tasks
, tree: (NTree (LNode { id }) _) } = do
task <- uploadArbitraryFile p.session id { blob, mName }
liftEffect $ do
mT <- T.read tasks
case mT of
Just t -> snd t $ GAT.Insert id task
Nothing -> pure unit
snd tasks $ GAT.Insert id task
log2 "[performAction] UploadArbitraryFile, uploaded, task:" task
performAction DownloadNode _ = liftEffect $ log "[performAction] DownloadNode"
performAction (MoveNode {params}) p@{ forestOpen
...
...
src/Gargantext/Components/Forest/Tree/Node.purs
View file @
d5c430c4
...
...
@@ -5,7 +5,7 @@ import Gargantext.Prelude
import Data.Maybe (Maybe(..))
import Data.Nullable (null)
import Data.Symbol (SProxy(..))
import Data.Tuple (snd)
import Data.Tuple (
fst,
snd)
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Aff (Aff, launchAff)
...
...
@@ -54,7 +54,7 @@ type NodeMainSpanProps =
, reloadRoot :: T.Box T2.Reload
, route :: T.Box Routes.AppRoute
, setPopoverRef :: R.Ref (Maybe (Boolean -> Effect Unit))
, tasks ::
T.Box (Maybe GAT.Reductor)
, tasks ::
GAT.Reductor
| CommonProps
)
...
...
@@ -101,7 +101,7 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt
R.setRef setPopoverRef $ Just $ Popover.setOpen popoverRef
let isSelected = Just route' == Routes.nodeTypeAppRoute nodeType (sessionId session) id
tasks' <- T.read tasks
--
tasks' <- T.read tasks
pure $ H.span (dropProps droppedFile droppedFile' isDragOver isDragOver')
$ reverseHanded handed
...
...
@@ -117,7 +117,7 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt
, onFinish: onTaskFinish id t
, session
}
) $ GAT.getTasks
Maybe tasks'
id
) $ GAT.getTasks
(fst tasks)
id
)
, if nodeType == GT.NodeUser
then GV.versionView {session}
...
...
@@ -142,10 +142,11 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt
]
where
onTaskFinish id' t _ = do
mT <- T.read tasks
case mT of
Just t' -> snd t' $ GAT.Finish id' t
Nothing -> pure unit
snd tasks $ GAT.Finish id' t
-- mT <- T.read tasks
-- case mT of
-- Just t' -> snd t' $ GAT.Finish id' t
-- Nothing -> pure unit
T2.reload reloadRoot
SettingsBox {show: showBox} = settingsBox nodeType
...
...
src/Gargantext/Components/GraphExplorer.purs
View file @
d5c430c4
...
...
@@ -53,7 +53,7 @@ type BaseProps =
, route :: T.Box AppRoute
, sessions :: T.Box Sessions
, showLogin :: T.Box Boolean
, tasks ::
T.Box (Maybe GAT.Reductor)
, tasks ::
GAT.Reductor
)
type LayoutLoaderProps = ( session :: R.Context Session | BaseProps )
...
...
@@ -277,7 +277,7 @@ type TreeProps = (
, sessions :: T.Box Sessions
, show :: Boolean
, showLogin :: T.Box Boolean
, tasks ::
T.Box (Maybe GAT.Reductor)
, tasks ::
GAT.Reductor
)
type MSidebarProps =
...
...
src/Gargantext/Components/NgramsTable.purs
View file @
d5c430c4
...
...
@@ -263,7 +263,7 @@ type CommonProps = (
, reloadRoot :: T.Box T2.Reload
, sidePanelTriggers :: Record NT.SidePanelTriggers
, tabNgramType :: CTabNgramType
, tasks ::
T.Box (Maybe GAT.Reductor)
, tasks ::
GAT.Reductor
, withAutoUpdate :: Boolean
)
...
...
src/Gargantext/Components/NgramsTable/Core.purs
View file @
d5c430c4
...
...
@@ -1184,7 +1184,7 @@ chartsAfterSync :: forall props discard.
, tabType :: TabType
| props
}
->
T.Box (Maybe GAT.Reductor)
->
GAT.Reductor
-> T.Box T2.Reload
-> discard
-> Aff Unit
...
...
@@ -1192,12 +1192,8 @@ chartsAfterSync path'@{ nodeId } tasks reloadForest _ = do
task <- postNgramsChartsAsync path'
liftEffect $ do
log2 "[chartsAfterSync] Synchronize task" task
mT <- T.read tasks
case mT of
Nothing -> log "[chartsAfterSync] tasks is Nothing"
Just tasks' -> do
snd tasks' (GAT.Insert nodeId task) -- *> T2.reload reloadForest
T2.reload reloadForest
snd tasks $ GAT.Insert nodeId task
T2.reload reloadForest
postNgramsChartsAsync :: forall s. CoreParams s -> Aff AsyncTaskWithType
postNgramsChartsAsync { listIds, nodeId, session, tabType } = do
...
...
src/Gargantext/Components/Nodes/Annuaire/Tabs.purs
View file @
d5c430c4
...
...
@@ -59,7 +59,7 @@ type TabsProps =
, reloadRoot :: T.Box T2.Reload
, session :: Session
, sidePanelTriggers :: Record LTypes.SidePanelTriggers
, tasks ::
T.Box (Maybe GAT.Reductor)
, tasks ::
GAT.Reductor
)
tabs :: R2.Leaf TabsProps
...
...
@@ -136,5 +136,5 @@ type NTCommon =
, reloadRoot :: T.Box T2.Reload
, session :: Session
, sidePanelTriggers :: Record LTypes.SidePanelTriggers
, tasks ::
T.Box (Maybe GAT.Reductor)
, tasks ::
GAT.Reductor
)
src/Gargantext/Components/Nodes/Annuaire/User.purs
View file @
d5c430c4
...
...
@@ -155,7 +155,7 @@ type LayoutNoSessionProps =
, nodeId :: Int
, reloadForest :: T.Box T2.Reload
, reloadRoot :: T.Box T2.Reload
, tasks ::
T.Box (Maybe GAT.Reductor)
, tasks ::
GAT.Reductor
)
type LayoutProps = WithSession LayoutNoSessionProps
...
...
src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs
View file @
d5c430c4
...
...
@@ -141,7 +141,7 @@ listElement = H.li { className: "list-group-item justify-content-between" }
type BasicProps =
( frontends :: Frontends
, nodeId :: Int
, tasks ::
T.Box (Maybe GAT.Reductor)
, tasks ::
GAT.Reductor
)
type ReloadProps =
...
...
src/Gargantext/Components/Nodes/Annuaire/User/Contacts/Tabs.purs
View file @
d5c430c4
...
...
@@ -57,7 +57,7 @@ type TabsProps = (
, reloadRoot :: T.Box T2.Reload
, session :: Session
, sidePanelTriggers :: Record LTypes.SidePanelTriggers
, tasks ::
T.Box (Maybe GAT.Reductor)
, tasks ::
GAT.Reductor
)
tabs :: Record TabsProps -> R.Element
...
...
@@ -139,7 +139,7 @@ type NgramsViewTabsProps = (
, reloadRoot :: T.Box T2.Reload
, session :: Session
, sidePanelTriggers :: Record LTypes.SidePanelTriggers
, tasks ::
T.Box (Maybe GAT.Reductor)
, tasks ::
GAT.Reductor
)
ngramsView :: R2.Component NgramsViewTabsProps
...
...
src/Gargantext/Components/Nodes/Lists.purs
View file @
d5c430c4
...
...
@@ -98,7 +98,7 @@ type CommonPropsNoSession =
, reloadForest :: T.Box T2.Reload
, reloadRoot :: T.Box T2.Reload
, sessionUpdate :: Session -> Effect Unit
, tasks ::
T.Box (Maybe GAT.Reductor)
, tasks ::
GAT.Reductor
)
type CommonProps = WithSession CommonPropsNoSession
...
...
src/Gargantext/Components/Nodes/Lists/Tabs.purs
View file @
d5c430c4
...
...
@@ -41,7 +41,7 @@ type Props = (
, reloadRoot :: T.Box T2.Reload
, session :: Session
, sidePanelTriggers :: Record SidePanelTriggers
, tasks ::
T.Box (Maybe GAT.Reductor)
, tasks ::
GAT.Reductor
)
type PropsWithKey = ( key :: String | Props )
...
...
src/Gargantext/Components/Router.purs
View file @
d5c430c4
...
...
@@ -42,7 +42,7 @@ import Gargantext.Utils.Reactix as R2
here :: R2.Here
here = R2.here "Gargantext.Components.Router"
type Props = ( boxes :: Boxes, tasks ::
T.Box (Maybe GAT.Reductor)
)
type Props = ( boxes :: Boxes, tasks ::
GAT.Reductor
)
type SessionProps = ( session :: R.Context Session, sessionId :: SessionId | Props )
...
...
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