Commit bcc6aaa6 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[ngrams] asyncTasks – pass action only

parent c37cc12f
......@@ -54,6 +54,7 @@ type ReductorProps = (
)
type Reductor = R2.Reductor (Record ReductorProps) Action
type ReductorAction = Action -> Effect Unit
useTasks :: R.State Int -> R.Hooks Reductor
useTasks reload = R2.useReductor act initializer unit
......
......@@ -91,7 +91,12 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
false ->
case fst route of
Annuaire sid nodeId -> withSession sid $ \session -> forested $ annuaireLayout { frontends, nodeId, session }
ContactPage sid aId nodeId -> withSession sid $ \session -> forested $ annuaireUserLayout { annuaireId: aId, asyncTasks, frontends, nodeId, session }
ContactPage sid aId nodeId -> withSession sid $ \session -> forested $ annuaireUserLayout {
annuaireId: aId
, asyncTasks: snd asyncTasks, frontends
, nodeId
, session
}
Corpus sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
CorpusDocument sid corpusId listId nodeId -> withSession sid $ \session -> forested $ documentLayout { nodeId, listId, session, corpusId: Just corpusId }
Dashboard sid nodeId -> withSession sid $ \session -> forested $ dashboardLayout { nodeId, session }
......@@ -103,7 +108,12 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
FolderPublic sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
FolderShared sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
Home -> forested $ homeLayout { backend, lang:LL_EN, publicBackend, sessions, visible: showLogin }
Lists sid nodeId -> withSession sid $ \session -> forested $ listsLayout { asyncTasks, nodeId, session, sessionUpdate }
Lists sid nodeId -> withSession sid $ \session -> forested $ listsLayout {
asyncTasks: snd asyncTasks
, nodeId
, session
, sessionUpdate
}
Login -> login { backend, backends, sessions, visible: showLogin }
PGraphExplorer sid graphId ->
withSession sid $
......@@ -126,7 +136,12 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
RouteFrameWrite sid nodeId -> withSession sid $ \session -> forested $ frameLayout { nodeId, session, nodeType: GT.NodeFrameWrite}
Team sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
Texts sid nodeId -> withSession sid $ \session -> forested $ textsLayout { frontends, nodeId, session, sessionUpdate }
UserPage sid nodeId -> withSession sid $ \session -> forested $ userLayout { asyncTasks, frontends, nodeId, session }
UserPage sid nodeId -> withSession sid $ \session -> forested $ userLayout {
asyncTasks: snd asyncTasks
, frontends
, nodeId
, session
}
type ForestLayoutProps =
( asyncTasks :: GAT.Reductor
......
......@@ -280,7 +280,7 @@ tableContainerCpt { dispatch
-- NEXT
type Props = (
afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.Reductor
, asyncTasks :: GAT.ReductorAction
, path :: R.State PageParams
, state :: R.State State
, tabNgramType :: CTabNgramType
......@@ -341,7 +341,7 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable"
task <- postNgramsChartsAsync path'
liftEffect $ do
log2 "[performAction] Synchronize task" task
snd asyncTasks $ GAT.Insert nodeId task
asyncTasks $ GAT.Insert nodeId task
autoUpdate :: Array R.Element
autoUpdate = if withAutoUpdate then
......@@ -495,7 +495,7 @@ selectNgramsOnFirstPage rows = Set.fromFoldable $ (view $ _NgramsElement <<< _ng
type MainNgramsTableProps = (
afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.Reductor
, asyncTasks :: GAT.ReductorAction
, cacheState :: R.State NT.CacheState
, defaultListId :: Int
, nodeId :: Int
......@@ -587,7 +587,7 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
type MainNgramsTablePaintProps = (
afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.Reductor
, asyncTasks :: GAT.ReductorAction
, path :: PageParams
, tabNgramType :: CTabNgramType
, versioned :: VersionedNgramsTable
......@@ -614,33 +614,33 @@ mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTable
, withAutoUpdate
}
type MainNgramsTablePaintWithStateProps = (
afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.Reductor
, path :: R.State PageParams
, tabNgramType :: CTabNgramType
, versioned :: VersionedNgramsTable
, withAutoUpdate :: Boolean
)
mainNgramsTablePaintWithState :: Record MainNgramsTablePaintWithStateProps -> R.Element
mainNgramsTablePaintWithState p = R.createElement mainNgramsTablePaintWithStateCpt p []
mainNgramsTablePaintWithStateCpt :: R.Component MainNgramsTablePaintWithStateProps
mainNgramsTablePaintWithStateCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaintWithState" cpt
where
cpt { afterSync, asyncTasks, path, tabNgramType, versioned, withAutoUpdate } _ = do
state <- R.useState' $ initialState versioned
pure $ loadedNgramsTable {
afterSync
, asyncTasks
, path
, state
, tabNgramType
, versioned
, withAutoUpdate
}
-- type MainNgramsTablePaintWithStateProps = (
-- afterSync :: Unit -> Aff Unit
-- , asyncTasks :: GAT.Reductor
-- , path :: R.State PageParams
-- , tabNgramType :: CTabNgramType
-- , versioned :: VersionedNgramsTable
-- , withAutoUpdate :: Boolean
-- )
-- mainNgramsTablePaintWithState :: Record MainNgramsTablePaintWithStateProps -> R.Element
-- mainNgramsTablePaintWithState p = R.createElement mainNgramsTablePaintWithStateCpt p []
-- mainNgramsTablePaintWithStateCpt :: R.Component MainNgramsTablePaintWithStateProps
-- mainNgramsTablePaintWithStateCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaintWithState" cpt
-- where
-- cpt { afterSync, asyncTasks, path, tabNgramType, versioned, withAutoUpdate } _ = do
-- state <- R.useState' $ initialState versioned
-- pure $ loadedNgramsTable {
-- afterSync
-- , asyncTasks
-- , path
-- , state
-- , tabNgramType
-- , versioned
-- , withAutoUpdate
-- }
type NgramsOcc = { occurrences :: Additive Int, children :: Set NgramsTerm }
......
......@@ -145,10 +145,10 @@ infoRender (Tuple title content) =
, H.span {} [H.text content] ]
type LayoutProps = (
asyncTasks :: GAT.Reductor
, frontends :: Frontends
, nodeId :: Int
, session :: Session
asyncTasks :: GAT.ReductorAction
, frontends :: Frontends
, nodeId :: Int
, session :: Session
)
type KeyLayoutProps = (
......
......@@ -44,12 +44,12 @@ modeTabType' Books = CTabAuthors
modeTabType' Communication = CTabAuthors
type TabsProps = (
asyncTasks :: GAT.Reductor
, cacheState :: R.State NTypes.CacheState
asyncTasks :: GAT.ReductorAction
, cacheState :: R.State NTypes.CacheState
, contactData :: ContactData
, frontends :: Frontends
, nodeId :: Int
, session :: Session
, frontends :: Frontends
, nodeId :: Int
, session :: Session
)
tabs :: Record TabsProps -> R.Element
......@@ -91,12 +91,12 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
type NgramsViewTabsProps = (
asyncTasks :: GAT.Reductor
, cacheState :: R.State NTypes.CacheState
asyncTasks :: GAT.ReductorAction
, cacheState :: R.State NTypes.CacheState
, defaultListId :: Int
, mode :: Mode
, nodeId :: Int
, session :: Session
, mode :: Mode
, nodeId :: Int
, session :: Session
)
ngramsView :: Record NgramsViewTabsProps -> R.Element
......
......@@ -30,6 +30,7 @@ import Gargantext.Types (NodeType(..), AffTableResult)
import Gargantext.Utils.Crypto as Crypto
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Nodes.Corpus"
type Props =
......
......@@ -25,7 +25,7 @@ thisModule = "Gargantext.Components.Nodes.Lists"
------------------------------------------------------------------------
type Props = (
asyncTasks :: GAT.Reductor
asyncTasks :: GAT.ReductorAction
, nodeId :: Int
, session :: Session
, sessionUpdate :: Session -> Effect Unit
......
......@@ -26,7 +26,7 @@ thisModule :: String
thisModule = "Gargantext.Components.Nodes.Lists.Tabs"
type Props = (
asyncTasks :: GAT.Reductor
asyncTasks :: GAT.ReductorAction
, cacheState :: R.State NTypes.CacheState
, corpusData :: CorpusData
, corpusId :: Int
......
......@@ -11,6 +11,7 @@ import Effect.Aff (launchAff_)
import Reactix as R
import Reactix.DOM.HTML as H
--------------------------------------------------------
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.DocsTable as DT
import Gargantext.Components.Loader (loader)
import Gargantext.Components.NgramsTable.Loader (clearCache)
......@@ -163,58 +164,68 @@ docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt
-- docViewLayoutRec :: forall a. DocViewProps a -> Record DT.LayoutProps
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabDocs } =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, cacheState
{ cacheState
, chart : H.div {} []
, tabType: TabCorpus TabDocs
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId
, frontends
, listId: defaultListId
, nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, session
, showSearch: true
, frontends, session }
, tabType: TabCorpus TabDocs
, totalRecords: 4737
}
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabMoreLikeFav } =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, cacheState
{ cacheState
, chart : H.div {} []
, tabType: TabCorpus TabMoreLikeFav
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId
, frontends
, listId: defaultListId
, nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, session
, showSearch: false
, frontends, session }
, tabType: TabCorpus TabMoreLikeFav
, totalRecords: 4737
}
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabMoreLikeTrash } =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, cacheState
{ cacheState
, chart : H.div {} []
, tabType: TabCorpus TabMoreLikeTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId
, frontends
, listId: defaultListId
, nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, session
, showSearch: false
, frontends, session }
, tabType: TabCorpus TabMoreLikeTrash
, totalRecords: 4737
}
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabTrash } =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, cacheState
{ cacheState
, chart : H.div {} []
, tabType: TabCorpus TabTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Nothing
, frontends
, listId: defaultListId
, nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, session
, showSearch: true
, frontends, session }
, tabType: TabCorpus TabTrash
, totalRecords: 4737
}
-- DUMMY
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType } =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, cacheState
{ cacheState
, chart : H.div {} []
, tabType: TabCorpus TabTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Nothing
, frontends
, listId: defaultListId
, nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, session
, showSearch: true
, frontends, session }
, tabType: TabCorpus TabTrash
, totalRecords: 4737
}
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