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