Commit 6abd6697 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[ngrams] asyncTasksRef

parent bcc6aaa6
...@@ -52,20 +52,20 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where ...@@ -52,20 +52,20 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
sessions <- useSessions sessions <- useSessions
route <- useHashRouter router Home route <- useHashRouter router Home
asyncTasksRef <- R.useRef Nothing
showLogin <- R.useState' false showLogin <- R.useState' false
backend <- R.useState' Nothing backend <- R.useState' Nothing
treeReload <- R.useState' 0 treeReload <- R.useState' 0
asyncTasks <- GAT.useTasks treeReload
showCorpus <- R.useState' false showCorpus <- R.useState' false
handed <- R.useState' GT.RightHanded handed <- R.useState' GT.RightHanded
let backends = fromFoldable defaultBackends let backends = fromFoldable defaultBackends
let ff f session = R.fragment [ f session, footer { session } ] let ff f session = R.fragment [ f session, footer { session } ]
let forested child = forestLayout { asyncTasks let forested child = forestLayout { asyncTasksRef
, child , child
, frontends , frontends
, handed , handed
...@@ -93,12 +93,13 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where ...@@ -93,12 +93,13 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
Annuaire sid nodeId -> withSession sid $ \session -> forested $ annuaireLayout { frontends, nodeId, session } Annuaire sid nodeId -> withSession sid $ \session -> forested $ annuaireLayout { frontends, nodeId, session }
ContactPage sid aId nodeId -> withSession sid $ \session -> forested $ annuaireUserLayout { ContactPage sid aId nodeId -> withSession sid $ \session -> forested $ annuaireUserLayout {
annuaireId: aId annuaireId: aId
, asyncTasks: snd asyncTasks, frontends , asyncTasksRef
, frontends
, nodeId , nodeId
, session , session
} }
Corpus sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { 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 } CorpusDocument sid corpusId listId nodeId -> withSession sid $ \session -> forested $ documentLayout { corpusId: Just corpusId, nodeId, listId, session }
Dashboard sid nodeId -> withSession sid $ \session -> forested $ dashboardLayout { nodeId, session } Dashboard sid nodeId -> withSession sid $ \session -> forested $ dashboardLayout { nodeId, session }
Document sid listId nodeId -> Document sid listId nodeId ->
withSession sid $ withSession sid $
...@@ -109,7 +110,7 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where ...@@ -109,7 +110,7 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
FolderShared 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 } Home -> forested $ homeLayout { backend, lang:LL_EN, publicBackend, sessions, visible: showLogin }
Lists sid nodeId -> withSession sid $ \session -> forested $ listsLayout { Lists sid nodeId -> withSession sid $ \session -> forested $ listsLayout {
asyncTasks: snd asyncTasks asyncTasksRef
, nodeId , nodeId
, session , session
, sessionUpdate , sessionUpdate
...@@ -119,7 +120,7 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where ...@@ -119,7 +120,7 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
withSession sid $ withSession sid $
\session -> \session ->
simpleLayout handed $ simpleLayout handed $
explorerLayout { asyncTasks explorerLayout { asyncTasksRef
, backend , backend
, frontends , frontends
, graphId , graphId
...@@ -137,22 +138,22 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where ...@@ -137,22 +138,22 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
Team sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session } Team sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
Texts sid nodeId -> withSession sid $ \session -> forested $ textsLayout { frontends, nodeId, session, sessionUpdate } Texts sid nodeId -> withSession sid $ \session -> forested $ textsLayout { frontends, nodeId, session, sessionUpdate }
UserPage sid nodeId -> withSession sid $ \session -> forested $ userLayout { UserPage sid nodeId -> withSession sid $ \session -> forested $ userLayout {
asyncTasks: snd asyncTasks asyncTasksRef
, frontends , frontends
, nodeId , nodeId
, session , session
} }
type ForestLayoutProps = type ForestLayoutProps = (
( asyncTasks :: GAT.Reductor asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, backend :: R.State (Maybe Backend) , backend :: R.State (Maybe Backend)
, child :: R.Element , child :: R.Element
, frontends :: Frontends , frontends :: Frontends
, handed :: R.State GT.Handed , handed :: R.State GT.Handed
, reload :: R.State Int , reload :: R.State Int
, route :: AppRoute , route :: AppRoute
, sessions :: Sessions , sessions :: Sessions
, showLogin :: R.Setter Boolean , showLogin :: R.Setter Boolean
) )
forestLayout :: Record ForestLayoutProps -> R.Element forestLayout :: Record ForestLayoutProps -> R.Element
...@@ -170,7 +171,7 @@ forestLayoutMain props = R.createElement forestLayoutMainCpt props [] ...@@ -170,7 +171,7 @@ forestLayoutMain props = R.createElement forestLayoutMainCpt props []
forestLayoutMainCpt :: R.Component ForestLayoutProps forestLayoutMainCpt :: R.Component ForestLayoutProps
forestLayoutMainCpt = R.hooksComponentWithModule thisModule "forestLayoutMain" cpt forestLayoutMainCpt = R.hooksComponentWithModule thisModule "forestLayoutMain" cpt
where where
cpt { asyncTasks, child, frontends, handed, reload, route, sessions, showLogin, backend} _ = do cpt { asyncTasksRef, child, frontends, handed, reload, route, sessions, showLogin, backend} _ = do
let ordering = let ordering =
case fst handed of case fst handed of
GT.LeftHanded -> reverse GT.LeftHanded -> reverse
...@@ -178,7 +179,7 @@ forestLayoutMainCpt = R.hooksComponentWithModule thisModule "forestLayoutMain" c ...@@ -178,7 +179,7 @@ forestLayoutMainCpt = R.hooksComponentWithModule thisModule "forestLayoutMain" c
pure $ R2.row $ ordering [ pure $ R2.row $ ordering [
H.div { className: "col-md-2", style: { paddingTop: "60px" } } H.div { className: "col-md-2", style: { paddingTop: "60px" } }
[ forest { asyncTasks, backend, frontends, handed: fst handed, reload, route, sessions, showLogin } ] [ forest { asyncTasksRef, backend, frontends, handed: fst handed, reload, route, sessions, showLogin } ]
, mainPage child , mainPage child
] ]
......
...@@ -21,15 +21,15 @@ import Gargantext.Utils.Reactix as R2 ...@@ -21,15 +21,15 @@ import Gargantext.Utils.Reactix as R2
thisModule :: String thisModule :: String
thisModule = "Gargantext.Components.Forest" thisModule = "Gargantext.Components.Forest"
type Props = type Props = (
( asyncTasks :: GAT.Reductor asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, backend :: R.State (Maybe Backend) , backend :: R.State (Maybe Backend)
, frontends :: Frontends , frontends :: Frontends
, handed :: Handed , handed :: Handed
, reload :: R.State Int , reload :: R.State Int
, route :: AppRoute , route :: AppRoute
, sessions :: Sessions , sessions :: Sessions
, showLogin :: R.Setter Boolean , showLogin :: R.Setter Boolean
) )
forest :: Record Props -> R.Element forest :: Record Props -> R.Element
...@@ -37,12 +37,17 @@ forest props = R.createElement forestCpt props [] ...@@ -37,12 +37,17 @@ forest props = R.createElement forestCpt props []
forestCpt :: R.Component Props forestCpt :: R.Component Props
forestCpt = R.hooksComponentWithModule thisModule "forest" cpt where forestCpt = R.hooksComponentWithModule thisModule "forest" cpt where
cpt { asyncTasks, frontends, handed, reload: extReload, route, sessions, showLogin, backend} _ = do cpt { asyncTasksRef, frontends, handed, reload: extReload, route, sessions, showLogin, backend} _ = do
-- NOTE: this is a hack to reload the tree view on demand -- NOTE: this is a hack to reload the tree view on demand
asyncTasks <- GAT.useTasks extReload
reload <- R.useState' (0 :: Reload) reload <- R.useState' (0 :: Reload)
openNodes <- R2.useLocalStorageState R2.openNodesKey (Set.empty :: OpenNodes) openNodes <- R2.useLocalStorageState R2.openNodesKey (Set.empty :: OpenNodes)
R2.useCache
( frontends R.useEffect' $ do
R.setRef asyncTasksRef $ Just asyncTasks
R2.useCache (
frontends
/\ route /\ route
/\ sessions /\ sessions
/\ fst openNodes /\ fst openNodes
......
...@@ -42,7 +42,7 @@ thisModule :: String ...@@ -42,7 +42,7 @@ thisModule :: String
thisModule = "Gargantext.Components.GraphExplorer" thisModule = "Gargantext.Components.GraphExplorer"
type LayoutProps = ( type LayoutProps = (
asyncTasks :: GAT.Reductor asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, backend :: R.State (Maybe Backend) , backend :: R.State (Maybe Backend)
, frontends :: Frontends , frontends :: Frontends
, graphId :: GET.GraphId , graphId :: GET.GraphId
...@@ -92,7 +92,7 @@ explorer props = R.createElement explorerCpt props [] ...@@ -92,7 +92,7 @@ explorer props = R.createElement explorerCpt props []
explorerCpt :: R.Component Props explorerCpt :: R.Component Props
explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
where where
cpt props@{ asyncTasks cpt props@{ asyncTasksRef
, frontends , frontends
, graph , graph
, graphId , graphId
...@@ -157,7 +157,7 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt ...@@ -157,7 +157,7 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
[ inner handed [ inner handed
[ rowControls [ Controls.controls controls ] [ rowControls [ Controls.controls controls ]
, R2.row $ mainLayout handed $ , R2.row $ mainLayout handed $
tree { asyncTasks tree { asyncTasksRef
, backend , backend
, frontends , frontends
, handed , handed
...@@ -212,9 +212,9 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt ...@@ -212,9 +212,9 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
tree :: Record TreeProps -> R.Element tree :: Record TreeProps -> R.Element
tree { show: false } = RH.div { id: "tree" } [] tree { show: false } = RH.div { id: "tree" } []
tree { asyncTasks, backend, frontends, handed, mCurrentRoute: route, reload, sessions, showLogin } = tree { asyncTasksRef, backend, frontends, handed, mCurrentRoute: route, reload, sessions, showLogin } =
RH.div {className: "col-md-2 graph-tree"} [ RH.div {className: "col-md-2 graph-tree"} [
forest { asyncTasks, backend, frontends, handed, reload, route, sessions, showLogin } forest { asyncTasksRef, backend, frontends, handed, reload, route, sessions, showLogin }
] ]
mSidebar :: Maybe GET.MetaData mSidebar :: Maybe GET.MetaData
...@@ -226,7 +226,7 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt ...@@ -226,7 +226,7 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
type TreeProps = type TreeProps =
( (
asyncTasks :: GAT.Reductor asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, backend :: R.State (Maybe Backend) , backend :: R.State (Maybe Backend)
, frontends :: Frontends , frontends :: Frontends
, handed :: Types.Handed , handed :: Types.Handed
......
...@@ -22,7 +22,7 @@ import Data.Set as Set ...@@ -22,7 +22,7 @@ import Data.Set as Set
import Data.Symbol (SProxy(..)) import Data.Symbol (SProxy(..))
import Data.Tuple (Tuple(..), fst, snd) import Data.Tuple (Tuple(..), fst, snd)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2) import DOM.Simple.Console (log, log2)
import Effect (Effect) import Effect (Effect)
import Effect.Aff (Aff, launchAff_) import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
...@@ -280,7 +280,7 @@ tableContainerCpt { dispatch ...@@ -280,7 +280,7 @@ tableContainerCpt { dispatch
-- NEXT -- NEXT
type Props = ( type Props = (
afterSync :: Unit -> Aff Unit afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.ReductorAction , asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, path :: R.State PageParams , path :: R.State PageParams
, state :: R.State State , state :: R.State State
, tabNgramType :: CTabNgramType , tabNgramType :: CTabNgramType
...@@ -295,7 +295,7 @@ loadedNgramsTableCpt :: R.Component Props ...@@ -295,7 +295,7 @@ loadedNgramsTableCpt :: R.Component Props
loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable" cpt loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable" cpt
where where
cpt { afterSync cpt { afterSync
, asyncTasks , asyncTasksRef
, path: path@(path'@{ listIds, nodeId, params, searchQuery, scoreType, termListFilter, termSizeFilter } /\ setPath) , path: path@(path'@{ listIds, nodeId, params, searchQuery, scoreType, termListFilter, termSizeFilter } /\ setPath)
, state: (state@{ ngramsChildren , state: (state@{ ngramsChildren
, ngramsLocalPatch , ngramsLocalPatch
...@@ -341,7 +341,9 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable" ...@@ -341,7 +341,9 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable"
task <- postNgramsChartsAsync path' task <- postNgramsChartsAsync path'
liftEffect $ do liftEffect $ do
log2 "[performAction] Synchronize task" task log2 "[performAction] Synchronize task" task
asyncTasks $ GAT.Insert nodeId task case R.readRef asyncTasksRef of
Nothing -> log "[performAction] asyncTasksRef is Nothing"
Just asyncTasks -> snd asyncTasks $ GAT.Insert nodeId task
autoUpdate :: Array R.Element autoUpdate :: Array R.Element
autoUpdate = if withAutoUpdate then autoUpdate = if withAutoUpdate then
...@@ -494,15 +496,15 @@ selectNgramsOnFirstPage rows = Set.fromFoldable $ (view $ _NgramsElement <<< _ng ...@@ -494,15 +496,15 @@ selectNgramsOnFirstPage rows = Set.fromFoldable $ (view $ _NgramsElement <<< _ng
type MainNgramsTableProps = ( type MainNgramsTableProps = (
afterSync :: Unit -> Aff Unit afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.ReductorAction , asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NT.CacheState , cacheState :: R.State NT.CacheState
, defaultListId :: Int , defaultListId :: Int
, nodeId :: Int , nodeId :: Int
-- ^ This node can be a corpus or contact. -- ^ This node can be a corpus or contact.
, session :: Session , session :: Session
, tabNgramType :: CTabNgramType , tabNgramType :: CTabNgramType
, tabType :: TabType , tabType :: TabType
, withAutoUpdate :: Boolean , withAutoUpdate :: Boolean
) )
...@@ -513,7 +515,7 @@ mainNgramsTableCpt :: R.Component MainNgramsTableProps ...@@ -513,7 +515,7 @@ mainNgramsTableCpt :: R.Component MainNgramsTableProps
mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
where where
cpt props@{ afterSync cpt props@{ afterSync
, asyncTasks , asyncTasksRef
, cacheState , cacheState
, defaultListId , defaultListId
, nodeId , nodeId
...@@ -523,7 +525,7 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt ...@@ -523,7 +525,7 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
, withAutoUpdate } _ = do , withAutoUpdate } _ = do
let path = initialPageParams session nodeId [defaultListId] tabType let path = initialPageParams session nodeId [defaultListId] tabType
let render versioned = mainNgramsTablePaint { afterSync let render versioned = mainNgramsTablePaint { afterSync
, asyncTasks , asyncTasksRef
, path , path
, tabNgramType , tabNgramType
, versioned , versioned
...@@ -587,7 +589,7 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt ...@@ -587,7 +589,7 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
type MainNgramsTablePaintProps = ( type MainNgramsTablePaintProps = (
afterSync :: Unit -> Aff Unit afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.ReductorAction , asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, path :: PageParams , path :: PageParams
, tabNgramType :: CTabNgramType , tabNgramType :: CTabNgramType
, versioned :: VersionedNgramsTable , versioned :: VersionedNgramsTable
...@@ -600,13 +602,13 @@ mainNgramsTablePaint p = R.createElement mainNgramsTablePaintCpt p [] ...@@ -600,13 +602,13 @@ mainNgramsTablePaint p = R.createElement mainNgramsTablePaintCpt p []
mainNgramsTablePaintCpt :: R.Component MainNgramsTablePaintProps mainNgramsTablePaintCpt :: R.Component MainNgramsTablePaintProps
mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaint" cpt mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaint" cpt
where where
cpt props@{ afterSync, asyncTasks, path, tabNgramType, versioned, withAutoUpdate } _ = do cpt props@{ afterSync, asyncTasksRef, path, tabNgramType, versioned, withAutoUpdate } _ = do
pathS <- R.useState' path pathS <- R.useState' path
state <- R.useState' $ initialState versioned state <- R.useState' $ initialState versioned
pure $ loadedNgramsTable { pure $ loadedNgramsTable {
afterSync afterSync
, asyncTasks , asyncTasksRef
, path: pathS , path: pathS
, state , state
, tabNgramType , tabNgramType
...@@ -616,7 +618,7 @@ mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTable ...@@ -616,7 +618,7 @@ mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTable
-- type MainNgramsTablePaintWithStateProps = ( -- type MainNgramsTablePaintWithStateProps = (
-- afterSync :: Unit -> Aff Unit -- afterSync :: Unit -> Aff Unit
-- , asyncTasks :: GAT.Reductor -- , asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
-- , path :: R.State PageParams -- , path :: R.State PageParams
-- , tabNgramType :: CTabNgramType -- , tabNgramType :: CTabNgramType
-- , versioned :: VersionedNgramsTable -- , versioned :: VersionedNgramsTable
...@@ -629,12 +631,12 @@ mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTable ...@@ -629,12 +631,12 @@ mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTable
-- mainNgramsTablePaintWithStateCpt :: R.Component MainNgramsTablePaintWithStateProps -- mainNgramsTablePaintWithStateCpt :: R.Component MainNgramsTablePaintWithStateProps
-- mainNgramsTablePaintWithStateCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaintWithState" cpt -- mainNgramsTablePaintWithStateCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaintWithState" cpt
-- where -- where
-- cpt { afterSync, asyncTasks, path, tabNgramType, versioned, withAutoUpdate } _ = do -- cpt { afterSync, asyncTasksRef, path, tabNgramType, versioned, withAutoUpdate } _ = do
-- state <- R.useState' $ initialState versioned -- state <- R.useState' $ initialState versioned
-- pure $ loadedNgramsTable { -- pure $ loadedNgramsTable {
-- afterSync -- afterSync
-- , asyncTasks -- , asyncTasksRef
-- , path -- , path
-- , state -- , state
-- , tabNgramType -- , tabNgramType
......
...@@ -145,10 +145,10 @@ infoRender (Tuple title content) = ...@@ -145,10 +145,10 @@ infoRender (Tuple title content) =
, H.span {} [H.text content] ] , H.span {} [H.text content] ]
type LayoutProps = ( type LayoutProps = (
asyncTasks :: GAT.ReductorAction asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, frontends :: Frontends , frontends :: Frontends
, nodeId :: Int , nodeId :: Int
, session :: Session , session :: Session
) )
type KeyLayoutProps = ( type KeyLayoutProps = (
...@@ -162,10 +162,10 @@ userLayout props = R.createElement userLayoutCpt props [] ...@@ -162,10 +162,10 @@ userLayout props = R.createElement userLayoutCpt props []
userLayoutCpt :: R.Component LayoutProps userLayoutCpt :: R.Component LayoutProps
userLayoutCpt = R.hooksComponentWithModule thisModule "userLayout" cpt userLayoutCpt = R.hooksComponentWithModule thisModule "userLayout" cpt
where where
cpt { asyncTasks, frontends, nodeId, session } _ = do cpt { asyncTasksRef, frontends, nodeId, session } _ = do
let sid = sessionId session let sid = sessionId session
pure $ userLayoutWithKey { asyncTasks, frontends, key: show sid <> "-" <> show nodeId, nodeId, session } pure $ userLayoutWithKey { asyncTasksRef, frontends, key: show sid <> "-" <> show nodeId, nodeId, session }
userLayoutWithKey :: Record KeyLayoutProps -> R.Element userLayoutWithKey :: Record KeyLayoutProps -> R.Element
userLayoutWithKey props = R.createElement userLayoutWithKeyCpt props [] userLayoutWithKey props = R.createElement userLayoutWithKeyCpt props []
...@@ -173,7 +173,7 @@ userLayoutWithKey props = R.createElement userLayoutWithKeyCpt props [] ...@@ -173,7 +173,7 @@ userLayoutWithKey props = R.createElement userLayoutWithKeyCpt props []
userLayoutWithKeyCpt :: R.Component KeyLayoutProps userLayoutWithKeyCpt :: R.Component KeyLayoutProps
userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey" cpt userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey" cpt
where where
cpt { asyncTasks, frontends, nodeId, session } _ = do cpt { asyncTasksRef, frontends, nodeId, session } _ = do
reload <- R.useState' 0 reload <- R.useState' 0
cacheState <- R.useState' NT.CacheOn cacheState <- R.useState' NT.CacheOn
...@@ -182,7 +182,7 @@ userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey" ...@@ -182,7 +182,7 @@ userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey"
\contactData@{contactNode: Contact {name, hyperdata}} -> \contactData@{contactNode: Contact {name, hyperdata}} ->
H.ul { className: "col-md-12 list-group" } [ H.ul { className: "col-md-12 list-group" } [
display (fromMaybe "no name" name) (contactInfos hyperdata (onUpdateHyperdata reload)) display (fromMaybe "no name" name) (contactInfos hyperdata (onUpdateHyperdata reload))
, Tabs.tabs { asyncTasks, cacheState, contactData, frontends, nodeId, session } , Tabs.tabs { asyncTasksRef, cacheState, contactData, frontends, nodeId, session }
] ]
where where
onUpdateHyperdata :: R.State Int -> HyperdataUser -> Effect Unit onUpdateHyperdata :: R.State Int -> HyperdataUser -> Effect Unit
...@@ -224,14 +224,14 @@ annuaireUserLayout props = R.createElement annuaireUserLayoutCpt props [] ...@@ -224,14 +224,14 @@ annuaireUserLayout props = R.createElement annuaireUserLayoutCpt props []
annuaireUserLayoutCpt :: R.Component AnnuaireLayoutProps annuaireUserLayoutCpt :: R.Component AnnuaireLayoutProps
annuaireUserLayoutCpt = R.hooksComponentWithModule thisModule "annuaireUserLayout" cpt annuaireUserLayoutCpt = R.hooksComponentWithModule thisModule "annuaireUserLayout" cpt
where where
cpt { annuaireId, asyncTasks, frontends, nodeId, session } _ = do cpt { annuaireId, asyncTasksRef, frontends, nodeId, session } _ = do
cacheState <- R.useState' NT.CacheOn cacheState <- R.useState' NT.CacheOn
useLoader nodeId (getAnnuaireContact session annuaireId) $ useLoader nodeId (getAnnuaireContact session annuaireId) $
\contactData@{contactNode: Contact {name, hyperdata}} -> \contactData@{contactNode: Contact {name, hyperdata}} ->
H.ul { className: "col-md-12 list-group" } H.ul { className: "col-md-12 list-group" }
[ display (fromMaybe "no name" name) (contactInfos hyperdata onUpdateHyperdata) [ display (fromMaybe "no name" name) (contactInfos hyperdata onUpdateHyperdata)
, Tabs.tabs { asyncTasks, cacheState, contactData, frontends, nodeId, session } ] , Tabs.tabs { asyncTasksRef, cacheState, contactData, frontends, nodeId, session } ]
where where
onUpdateHyperdata :: HyperdataUser -> Effect Unit onUpdateHyperdata :: HyperdataUser -> Effect Unit
......
...@@ -44,12 +44,12 @@ modeTabType' Books = CTabAuthors ...@@ -44,12 +44,12 @@ modeTabType' Books = CTabAuthors
modeTabType' Communication = CTabAuthors modeTabType' Communication = CTabAuthors
type TabsProps = ( type TabsProps = (
asyncTasks :: GAT.ReductorAction asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NTypes.CacheState , cacheState :: R.State NTypes.CacheState
, contactData :: ContactData , contactData :: ContactData
, frontends :: Frontends , frontends :: Frontends
, nodeId :: Int , nodeId :: Int
, session :: Session , session :: Session
) )
tabs :: Record TabsProps -> R.Element tabs :: Record TabsProps -> R.Element
...@@ -58,7 +58,7 @@ tabs props = R.createElement tabsCpt props [] ...@@ -58,7 +58,7 @@ tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component TabsProps tabsCpt :: R.Component TabsProps
tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
where where
cpt { asyncTasks, cacheState, contactData: {defaultListId}, frontends, nodeId, session} _ = do cpt { asyncTasksRef, cacheState, contactData: {defaultListId}, frontends, nodeId, session} _ = do
active <- R.useState' 0 active <- R.useState' 0
pure $ pure $
Tab.tabs { selected: fst active, tabs: tabs' } Tab.tabs { selected: fst active, tabs: tabs' }
...@@ -71,9 +71,9 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt ...@@ -71,9 +71,9 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
, "Trash" /\ docs -- TODO pass-in trash mode , "Trash" /\ docs -- TODO pass-in trash mode
] ]
where where
patentsView = { asyncTasks, cacheState, defaultListId, mode: Patents, nodeId, session } patentsView = { asyncTasksRef, cacheState, defaultListId, mode: Patents, nodeId, session }
booksView = { asyncTasks, cacheState, defaultListId, mode: Books, nodeId, session } booksView = { asyncTasksRef, cacheState, defaultListId, mode: Books, nodeId, session }
commView = { asyncTasks, cacheState, defaultListId, mode: Communication, nodeId, session } commView = { asyncTasksRef, cacheState, defaultListId, mode: Communication, nodeId, session }
chart = mempty chart = mempty
totalRecords = 4736 -- TODO totalRecords = 4736 -- TODO
docs = DT.docViewLayout docs = DT.docViewLayout
...@@ -91,7 +91,7 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt ...@@ -91,7 +91,7 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
type NgramsViewTabsProps = ( type NgramsViewTabsProps = (
asyncTasks :: GAT.ReductorAction asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NTypes.CacheState , cacheState :: R.State NTypes.CacheState
, defaultListId :: Int , defaultListId :: Int
, mode :: Mode , mode :: Mode
...@@ -100,10 +100,10 @@ type NgramsViewTabsProps = ( ...@@ -100,10 +100,10 @@ type NgramsViewTabsProps = (
) )
ngramsView :: Record NgramsViewTabsProps -> R.Element ngramsView :: Record NgramsViewTabsProps -> R.Element
ngramsView { asyncTasks, cacheState, defaultListId, mode, nodeId, session } = ngramsView { asyncTasksRef, cacheState, defaultListId, mode, nodeId, session } =
NT.mainNgramsTable { NT.mainNgramsTable {
afterSync: \_ -> pure unit afterSync: \_ -> pure unit
, asyncTasks , asyncTasksRef
, cacheState , cacheState
, defaultListId , defaultListId
, nodeId , nodeId
......
module Gargantext.Components.Nodes.Lists where module Gargantext.Components.Nodes.Lists where
import Data.Maybe (Maybe(..))
import Data.Tuple (fst) import Data.Tuple (fst)
import Effect (Effect) import Effect (Effect)
import Effect.Aff (launchAff_) import Effect.Aff (launchAff_)
...@@ -25,7 +26,7 @@ thisModule = "Gargantext.Components.Nodes.Lists" ...@@ -25,7 +26,7 @@ thisModule = "Gargantext.Components.Nodes.Lists"
------------------------------------------------------------------------ ------------------------------------------------------------------------
type Props = ( type Props = (
asyncTasks :: GAT.ReductorAction asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, nodeId :: Int , nodeId :: Int
, session :: Session , session :: Session
, sessionUpdate :: Session -> Effect Unit , sessionUpdate :: Session -> Effect Unit
...@@ -53,7 +54,7 @@ listsLayoutWithKey props = R.createElement listsLayoutWithKeyCpt props [] ...@@ -53,7 +54,7 @@ listsLayoutWithKey props = R.createElement listsLayoutWithKeyCpt props []
listsLayoutWithKeyCpt :: R.Component KeyProps listsLayoutWithKeyCpt :: R.Component KeyProps
listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKey" cpt listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKey" cpt
where where
cpt { asyncTasks, nodeId, session, sessionUpdate } _ = do cpt { asyncTasksRef, nodeId, session, sessionUpdate } _ = do
let path = { nodeId, session } let path = { nodeId, session }
cacheState <- R.useState' $ getCacheState NT.CacheOn session nodeId cacheState <- R.useState' $ getCacheState NT.CacheOn session nodeId
...@@ -74,7 +75,7 @@ listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKe ...@@ -74,7 +75,7 @@ listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKe
, title: "Corpus " <> name , title: "Corpus " <> name
, user: authors } , user: authors }
, Tabs.tabs { , Tabs.tabs {
asyncTasks asyncTasksRef
, cacheState , cacheState
, corpusData , corpusData
, corpusId , corpusId
......
...@@ -26,11 +26,11 @@ thisModule :: String ...@@ -26,11 +26,11 @@ thisModule :: String
thisModule = "Gargantext.Components.Nodes.Lists.Tabs" thisModule = "Gargantext.Components.Nodes.Lists.Tabs"
type Props = ( type Props = (
asyncTasks :: GAT.ReductorAction asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NTypes.CacheState , cacheState :: R.State NTypes.CacheState
, corpusData :: CorpusData , corpusData :: CorpusData
, corpusId :: Int , corpusId :: Int
, session :: Session , session :: Session
) )
type PropsWithKey = ( type PropsWithKey = (
...@@ -44,7 +44,7 @@ tabs props = R.createElement tabsCpt props [] ...@@ -44,7 +44,7 @@ tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component PropsWithKey tabsCpt :: R.Component PropsWithKey
tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
where where
cpt { asyncTasks, cacheState, corpusData: corpusData@{ defaultListId }, corpusId, session } _ = do cpt { asyncTasksRef, cacheState, corpusData: corpusData@{ defaultListId }, corpusId, session } _ = do
(selected /\ setSelected) <- R.useState' 0 (selected /\ setSelected) <- R.useState' 0
pure $ Tab.tabs { selected, tabs: tabs' } pure $ Tab.tabs { selected, tabs: tabs' }
...@@ -53,7 +53,7 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt ...@@ -53,7 +53,7 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
, "Institutes" /\ view Institutes , "Institutes" /\ view Institutes
, "Sources" /\ view Sources , "Sources" /\ view Sources
, "Terms" /\ view Terms ] , "Terms" /\ view Terms ]
view mode = ngramsView { asyncTasks, cacheState, corpusData, corpusId, mode, session } view mode = ngramsView { asyncTasksRef, cacheState, corpusData, corpusId, mode, session }
type NgramsViewProps = ( mode :: Mode | Props ) type NgramsViewProps = ( mode :: Mode | Props )
...@@ -63,7 +63,7 @@ ngramsView props = R.createElement ngramsViewCpt props [] ...@@ -63,7 +63,7 @@ ngramsView props = R.createElement ngramsViewCpt props []
ngramsViewCpt :: R.Component NgramsViewProps ngramsViewCpt :: R.Component NgramsViewProps
ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
where where
cpt { asyncTasks cpt { asyncTasksRef
, cacheState , cacheState
, corpusData: { defaultListId } , corpusData: { defaultListId }
, corpusId , corpusId
...@@ -76,7 +76,7 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt ...@@ -76,7 +76,7 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
pure $ R.fragment pure $ R.fragment
( charts tabNgramType chartType chartsReload ( charts tabNgramType chartType chartsReload
<> [ NT.mainNgramsTable { afterSync: afterSync chartsReload <> [ NT.mainNgramsTable { afterSync: afterSync chartsReload
, asyncTasks , asyncTasksRef
, cacheState , cacheState
, defaultListId , defaultListId
, nodeId: corpusId , nodeId: corpusId
......
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