Commit 13ea1281 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[ngramsTable] fixes to graph refreshing

Components are simplified, some duplicated props are removed.
parent 20bdba69
...@@ -513,11 +513,8 @@ selectNgramsOnFirstPage rows = Set.fromFoldable $ (view $ _NgramsElement <<< _ng ...@@ -513,11 +513,8 @@ selectNgramsOnFirstPage rows = Set.fromFoldable $ (view $ _NgramsElement <<< _ng
type MainNgramsTableProps = ( type MainNgramsTableProps = (
cacheState :: R.State NT.CacheState cacheState :: R.State NT.CacheState
, defaultListId :: Int , defaultListId :: Int
, nodeId :: Int
-- ^ This node can be a corpus or contact. -- ^ This node can be a corpus or contact.
, pathS :: R.State PageParams , path :: PageParams
, session :: Session
, tabType :: TabType
| CommonProps | CommonProps
) )
...@@ -531,12 +528,9 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt ...@@ -531,12 +528,9 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
, asyncTasksRef , asyncTasksRef
, cacheState , cacheState
, defaultListId , defaultListId
, nodeId , path
, pathS
, session
, sidePanelTriggers , sidePanelTriggers
, tabNgramType , tabNgramType
, tabType
, treeReloadRef , treeReloadRef
, withAutoUpdate } _ = do , withAutoUpdate } _ = do
...@@ -548,7 +542,7 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt ...@@ -548,7 +542,7 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
, appReload , appReload
, asyncTasksRef , asyncTasksRef
, cacheState: fst cacheState , cacheState: fst cacheState
, path: fst pathS , path
, sidePanelTriggers , sidePanelTriggers
, tabNgramType , tabNgramType
, treeReloadRef , treeReloadRef
...@@ -558,11 +552,11 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt ...@@ -558,11 +552,11 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
cacheEndpoint: versionEndpoint props cacheEndpoint: versionEndpoint props
, handleResponse , handleResponse
, mkRequest , mkRequest
, path: fst pathS , path
, renderer: render , renderer: render
} }
(NT.CacheOff /\ _) -> do (NT.CacheOff /\ _) -> do
-- pathS <- R.useState' path pathS <- R.useState' path
let render versionedWithCount = mainNgramsTablePaintNoCache { afterSync let render versionedWithCount = mainNgramsTablePaintNoCache { afterSync
, appReload , appReload
, asyncTasksRef , asyncTasksRef
...@@ -577,7 +571,7 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt ...@@ -577,7 +571,7 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
-- NOTE With cache on -- NOTE With cache on
versionEndpoint :: Record MainNgramsTableProps -> PageParams -> Aff Version versionEndpoint :: Record MainNgramsTableProps -> PageParams -> Aff Version
versionEndpoint { defaultListId, nodeId, session, tabType } _ = get session $ R.GetNgramsTableVersion { listId: defaultListId, tabType } (Just nodeId) versionEndpoint { defaultListId, path: { nodeId, tabType, session } } _ = get session $ R.GetNgramsTableVersion { listId: defaultListId, tabType } (Just nodeId)
-- NOTE With cache off -- NOTE With cache off
loader :: PageParams -> Aff VersionedWithCountNgramsTable loader :: PageParams -> Aff VersionedWithCountNgramsTable
......
...@@ -157,7 +157,7 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt ...@@ -157,7 +157,7 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
, session , session
, sidePanelTriggers , sidePanelTriggers
, treeReloadRef } _ = do , treeReloadRef } _ = do
pathS <- R.useState' $ NTC.initialPageParams session nodeId [defaultListId] (TabDocument TabDocs) let path = NTC.initialPageParams session nodeId [defaultListId] (TabDocument TabDocs)
pure $ NT.mainNgramsTable { pure $ NT.mainNgramsTable {
appReload appReload
...@@ -165,10 +165,7 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt ...@@ -165,10 +165,7 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
, asyncTasksRef , asyncTasksRef
, cacheState , cacheState
, defaultListId , defaultListId
, nodeId , path
, pathS
, tabType
, session
, sidePanelTriggers , sidePanelTriggers
, tabNgramType , tabNgramType
, treeReloadRef , treeReloadRef
......
...@@ -157,7 +157,7 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt ...@@ -157,7 +157,7 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
, session , session
, sidePanelTriggers , sidePanelTriggers
, treeReloadRef } _ = do , treeReloadRef } _ = do
pathS <- R.useState' $ NTC.initialPageParams session nodeId [defaultListId] (TabDocument TabDocs) let path = NTC.initialPageParams session nodeId [defaultListId] (TabDocument TabDocs)
pure $ NT.mainNgramsTable { pure $ NT.mainNgramsTable {
appReload appReload
...@@ -165,10 +165,7 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt ...@@ -165,10 +165,7 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
, asyncTasksRef , asyncTasksRef
, cacheState , cacheState
, defaultListId , defaultListId
, nodeId , path
, pathS
, tabType
, session
, sidePanelTriggers , sidePanelTriggers
, tabNgramType , tabNgramType
, treeReloadRef , treeReloadRef
......
...@@ -21,6 +21,7 @@ import Gargantext.Components.Nodes.Corpus.Chart.Tree (tree) ...@@ -21,6 +21,7 @@ import Gargantext.Components.Nodes.Corpus.Chart.Tree (tree)
import Gargantext.Components.Nodes.Corpus.Chart (getChartFunction) import Gargantext.Components.Nodes.Corpus.Chart (getChartFunction)
import Gargantext.Components.Nodes.Corpus.Chart.Utils (mNgramsTypeFromTabType) import Gargantext.Components.Nodes.Corpus.Chart.Utils (mNgramsTypeFromTabType)
import Gargantext.Components.Nodes.Lists.Types import Gargantext.Components.Nodes.Lists.Types
import Gargantext.Components.Search as S
import Gargantext.Components.Tab as Tab import Gargantext.Components.Tab as Tab
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (ChartType(..), CTabNgramType(..), Mode(..), TabSubType(..), TabType(..), chartTypeFromString, modeTabType) import Gargantext.Types (ChartType(..), CTabNgramType(..), Mode(..), TabSubType(..), TabType(..), chartTypeFromString, modeTabType)
...@@ -77,12 +78,12 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt ...@@ -77,12 +78,12 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
, mode , mode
, session , session
, sidePanelTriggers , sidePanelTriggers
, treeReloadRef } , treeReloadRef } []
type NgramsViewProps = ( mode :: Mode | Props ) type NgramsViewProps = ( mode :: Mode | Props )
ngramsView :: Record NgramsViewProps -> R.Element ngramsView :: R2.Component NgramsViewProps
ngramsView props = R.createElement ngramsViewCpt props [] ngramsView = R.createElement ngramsViewCpt
ngramsViewCpt :: R.Component NgramsViewProps ngramsViewCpt :: R.Component NgramsViewProps
ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
...@@ -100,19 +101,12 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt ...@@ -100,19 +101,12 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
chartType <- R.useState' Histo chartType <- R.useState' Histo
chartsReload <- GUR.new chartsReload <- GUR.new
pathS <- R.useState' $ NTC.initialPageParams session initialPath.corpusId [initialPath.listId] initialPath.tabType let path = NTC.initialPageParams session corpusId [listId] tabType
let listId' = fromMaybe defaultListId $ A.head (fst pathS).listIds
let path = {
corpusId: (fst pathS).nodeId
, limit: (fst pathS).params.limit
, listId: listId'
, tabType: (fst pathS).tabType
}
let chartParams = { let chartParams = {
corpusId: path.corpusId corpusId
, limit: Just path.limit , limit: Just path.params.limit
, listId: path.listId , listId
, tabType: path.tabType , tabType
} }
pure $ R.fragment pure $ R.fragment
...@@ -122,12 +116,9 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt ...@@ -122,12 +116,9 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
, asyncTasksRef , asyncTasksRef
, cacheState , cacheState
, defaultListId , defaultListId
, nodeId: corpusId , path
, pathS
, session
, sidePanelTriggers , sidePanelTriggers
, tabNgramType , tabNgramType
, tabType
, treeReloadRef , treeReloadRef
, withAutoUpdate: false , withAutoUpdate: false
} [] } []
......
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