Commit ba9e3372 authored by arturo's avatar arturo

[ngrams] Cache off search issue

* #367
parent 7f7afc2d
...@@ -7,7 +7,6 @@ module Gargantext.Components.NgramsTable ...@@ -7,7 +7,6 @@ module Gargantext.Components.NgramsTable
import Gargantext.Prelude import Gargantext.Prelude
import Data.Array as A import Data.Array as A
import Data.Either (Either)
import Data.FunctorWithIndex (mapWithIndex) import Data.FunctorWithIndex (mapWithIndex)
import Data.Lens (to, view, (%~), (.~), (^.), (^?)) import Data.Lens (to, view, (%~), (.~), (^.), (^?))
import Data.Lens.At (at) import Data.Lens.At (at)
...@@ -255,7 +254,7 @@ type CommonProps = ...@@ -255,7 +254,7 @@ type CommonProps =
( afterSync :: Unit -> Aff Unit ( afterSync :: Unit -> Aff Unit
, boxes :: Boxes , boxes :: Boxes
, tabNgramType :: CTabNgramType , tabNgramType :: CTabNgramType
, withAutoUpdate :: Boolean , withAutoUpdate :: Boolean -- (?) not used
) )
type PropsNoReload = type PropsNoReload =
...@@ -272,17 +271,6 @@ type Props = ...@@ -272,17 +271,6 @@ type Props =
, reloadRoot :: T2.ReloadS , reloadRoot :: T2.ReloadS
| PropsNoReload ) | PropsNoReload )
loadedNgramsTable :: R2.Component PropsNoReload
loadedNgramsTable = R.createElement loadedNgramsTableCpt
loadedNgramsTableCpt :: R.Component PropsNoReload
loadedNgramsTableCpt = here.component "loadedNgramsTable" cpt where
cpt props@{ path } _ = do
searchQuery <- T.useFocused (_.searchQuery) (\a b -> b { searchQuery = a }) path
pure $ R.fragment $
[ loadedNgramsTableHeader { searchQuery } []
, loadedNgramsTableBody props [] ]
type LoadedNgramsTableHeaderProps = type LoadedNgramsTableHeaderProps =
( searchQuery :: T.Box SearchQuery ) ( searchQuery :: T.Box SearchQuery )
...@@ -312,7 +300,7 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where ...@@ -312,7 +300,7 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where
, state , state
, tabNgramType , tabNgramType
, versioned: Versioned { data: initTable } , versioned: Versioned { data: initTable }
, withAutoUpdate } _ = do } _ = do
state'@{ ngramsChildren, ngramsLocalPatch, ngramsParent, ngramsSelection } <- T.useLive T.unequal state state'@{ ngramsChildren, ngramsLocalPatch, ngramsParent, ngramsSelection } <- T.useLive T.unequal state
path'@{ scoreType, termListFilter, termSizeFilter } <- T.useLive T.unequal path path'@{ scoreType, termListFilter, termSizeFilter } <- T.useLive T.unequal path
params <- T.useFocused (_.params) (\a b -> b { params = a }) path params <- T.useFocused (_.params) (\a b -> b { params = a }) path
...@@ -565,14 +553,26 @@ mainNgramsTable = R.createElement mainNgramsTableCpt ...@@ -565,14 +553,26 @@ mainNgramsTable = R.createElement mainNgramsTableCpt
mainNgramsTableCpt :: R.Component MainNgramsTableProps mainNgramsTableCpt :: R.Component MainNgramsTableProps
mainNgramsTableCpt = here.component "mainNgramsTable" cpt mainNgramsTableCpt = here.component "mainNgramsTable" cpt
where where
cpt props@{ cacheState } _ = do cpt props@{ cacheState, path } _ = do
searchQuery <- T.useFocused (_.searchQuery) (\a b -> b { searchQuery = a }) path
cacheState' <- T.useLive T.unequal cacheState cacheState' <- T.useLive T.unequal cacheState
-- let path = initialPageParams session nodeId [defaultListId] tabType -- let path = initialPageParams session nodeId [defaultListId] tabType
case cacheState' of case cacheState' of
NT.CacheOn -> pure $ mainNgramsTableCacheOn props [] NT.CacheOn -> pure $ R.fragment
NT.CacheOff -> pure $ mainNgramsTableCacheOff props [] [
loadedNgramsTableHeader { searchQuery } []
,
mainNgramsTableCacheOn props []
]
NT.CacheOff -> pure $ R.fragment
[
loadedNgramsTableHeader { searchQuery } []
,
mainNgramsTableCacheOff props []
]
mainNgramsTableCacheOn :: R2.Component MainNgramsTableProps mainNgramsTableCacheOn :: R2.Component MainNgramsTableProps
mainNgramsTableCacheOn = R.createElement mainNgramsTableCacheOnCpt mainNgramsTableCacheOn = R.createElement mainNgramsTableCacheOnCpt
...@@ -622,7 +622,6 @@ mainNgramsTableCacheOffCpt :: R.Component MainNgramsTableProps ...@@ -622,7 +622,6 @@ mainNgramsTableCacheOffCpt :: R.Component MainNgramsTableProps
mainNgramsTableCacheOffCpt = here.component "mainNgramsTableCacheOff" cpt where mainNgramsTableCacheOffCpt = here.component "mainNgramsTableCacheOff" cpt where
cpt { afterSync cpt { afterSync
, boxes , boxes
, defaultListId
, path , path
, tabNgramType , tabNgramType
, withAutoUpdate } _ = do , withAutoUpdate } _ = do
...@@ -685,16 +684,19 @@ mainNgramsTablePaintCpt = here.component "mainNgramsTablePaint" cpt ...@@ -685,16 +684,19 @@ mainNgramsTablePaintCpt = here.component "mainNgramsTablePaint" cpt
, withAutoUpdate } _ = do , withAutoUpdate } _ = do
state <- T.useBox $ initialState versioned state <- T.useBox $ initialState versioned
pure $ loadedNgramsTable { afterSync pure $
, boxes
, cacheState loadedNgramsTableBody
, mTotalRows: Nothing { afterSync
, path , boxes
, state , cacheState
, tabNgramType , mTotalRows: Nothing
, versioned , path
, withAutoUpdate , state
} [] , tabNgramType
, versioned
, withAutoUpdate
} []
type MainNgramsTablePaintNoCacheProps = ( type MainNgramsTablePaintNoCacheProps = (
cacheState :: NT.CacheState cacheState :: NT.CacheState
...@@ -720,15 +722,18 @@ mainNgramsTablePaintNoCacheCpt = here.component "mainNgramsTablePaintNoCache" cp ...@@ -720,15 +722,18 @@ mainNgramsTablePaintNoCacheCpt = here.component "mainNgramsTablePaintNoCache" cp
state <- T.useBox $ initialState versioned state <- T.useBox $ initialState versioned
pure $ loadedNgramsTable { afterSync pure $
, boxes
, cacheState loadedNgramsTableBody
, mTotalRows: Just count { afterSync
, path , boxes
, state , cacheState
, tabNgramType , mTotalRows: Just count
, versioned , path
, withAutoUpdate } [] , state
, tabNgramType
, versioned
, withAutoUpdate } []
type NgramsOcc = { occurrences :: Additive Int, children :: Set NgramsTerm } type NgramsOcc = { occurrences :: Additive Int, children :: Set NgramsTerm }
......
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