Commit 2bdf5821 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[refactor] add ReloadS state

parent 7d22a0a8
......@@ -49,8 +49,8 @@ removeTaskFromList ts (GT.AsyncTaskWithType { task: GT.AsyncTask { id: id' } })
A.filter (\(GT.AsyncTaskWithType { task: GT.AsyncTask { id: id'' } }) -> id' /= id'') ts
type ReductorProps = (
appReload :: R.State Int
, treeReload :: R.State Int
appReload :: GT.ReloadS
, treeReload :: GT.ReloadS
, storage :: Storage
)
......@@ -58,7 +58,7 @@ type Reductor = R2.Reductor (Record ReductorProps) Action
type ReductorAction = Action -> Effect Unit
type OnFinish = Effect Unit
useTasks :: R.State Int -> R.State Int -> R.Hooks Reductor
useTasks :: GT.ReloadS -> GT.ReloadS -> R.Hooks Reductor
useTasks appReload treeReload = R2.useReductor act initializer unit
where
act :: R2.Actor (Record ReductorProps) Action
......
......@@ -17,14 +17,14 @@ import Gargantext.Ends (Frontends, Backend(..))
import Gargantext.Prelude
import Gargantext.Routes (AppRoute)
import Gargantext.Sessions (Session(..), Sessions, OpenNodes, unSessions)
import Gargantext.Types (Reload, Handed(..))
import Gargantext.Types (Reload, ReloadS, Handed(..))
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Forest"
type Props = (
appReload :: R.State Int
appReload :: ReloadS
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, backend :: R.State (Maybe Backend)
, frontends :: Frontends
......@@ -32,7 +32,7 @@ type Props = (
, route :: AppRoute
, sessions :: Sessions
, showLogin :: R.Setter Boolean
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, treeReloadRef :: R.Ref (Maybe ReloadS)
)
forest :: Record Props -> R.Element
......@@ -115,7 +115,7 @@ plus handed showLogin backend = H.div { className: handedClass } [
-------------------------
type ForestLayoutProps = (
appReload :: R.State Int
appReload :: ReloadS
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, backend :: R.State (Maybe Backend)
, child :: R.Element
......@@ -124,7 +124,7 @@ type ForestLayoutProps = (
, route :: AppRoute
, sessions :: Sessions
, showLogin :: R.Setter Boolean
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, treeReloadRef :: R.Ref (Maybe ReloadS)
)
forestLayout :: Record ForestLayoutProps -> R.Element
......
......@@ -42,7 +42,7 @@ thisModule = "Gargantext.Components.Forest.Tree.Node"
-- Main Node
type NodeMainSpanProps = (
appReload :: R.State Int
appReload :: GT.ReloadS
, asyncTasks :: GAT.Reductor
, folderOpen :: R.State Boolean
, frontends :: Frontends
......
......@@ -55,7 +55,7 @@ type LayoutProps = (
type Props =
( graph :: SigmaxT.SGraph
, graphVersion :: R.State Int
, graphVersion :: Types.ReloadS
, hyperdataGraph :: GET.HyperdataGraph
, mMetaData :: Maybe GET.MetaData
| LayoutProps
......@@ -72,7 +72,7 @@ explorerLayoutCpt = R.hooksComponentWithModule thisModule "explorerLayout" cpt
graphVersion <- R.useState' 0
pure $ explorerLayoutView graphVersion props
explorerLayoutView :: R.State Int -> Record LayoutProps -> R.Element
explorerLayoutView :: Types.ReloadS -> Record LayoutProps -> R.Element
explorerLayoutView graphVersion p = R.createElement el p []
where
el = R.hooksComponentWithModule thisModule "explorerLayoutView" cpt
......@@ -242,23 +242,23 @@ type TreeProps =
, frontends :: Frontends
, handed :: Types.Handed
, mCurrentRoute :: AppRoute
, reload :: R.State Int
, reload :: Types.ReloadS
, sessions :: Sessions
, show :: Boolean
, showLogin :: R.Setter Boolean
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, treeReloadRef :: R.Ref (Maybe Types.ReloadS)
)
type MSidebarProps =
( frontends :: Frontends
, graph :: SigmaxT.SGraph
, graphId :: GET.GraphId
, graphVersion :: R.State Int
, graphVersion :: Types.ReloadS
, removedNodeIds :: R.State SigmaxT.NodeIds
, showSidePanel :: R.State GET.SidePanelState
, selectedNodeIds :: R.State SigmaxT.NodeIds
, session :: Session
, treeReload :: R.State Int
, treeReload :: Types.ReloadS
)
type GraphProps = (
......@@ -366,7 +366,7 @@ modeGraphType Types.Sources = "star"
modeGraphType Types.Terms = "def"
getNodes :: Session -> R.State Int -> GET.GraphId -> Aff GET.HyperdataGraph
getNodes :: Session -> Types.ReloadS -> GET.GraphId -> Aff GET.HyperdataGraph
getNodes session (graphVersion /\ _) graphId =
get session $ NodeAPI Types.Graph
(Just graphId)
......
......@@ -32,7 +32,7 @@ import Gargantext.Data.Array (mapMaybe)
import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Sigmax.Types as SigmaxT
import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType, TabSubType(..), TabType(..), TermList(..), modeTabType)
import Gargantext.Types (CTabNgramType, ReloadS, TabSubType(..), TabType(..), TermList(..), modeTabType)
import Gargantext.Utils.Reactix as R2
import Partial.Unsafe (unsafePartial)
......@@ -42,13 +42,13 @@ type Props =
( frontends :: Frontends
, graph :: SigmaxT.SGraph
, graphId :: Int
, graphVersion :: R.State Int
, graphVersion :: ReloadS
, metaData :: GET.MetaData
, removedNodeIds :: R.State SigmaxT.NodeIds
, selectedNodeIds :: R.State SigmaxT.NodeIds
, session :: Session
, showSidePanel :: R.State GET.SidePanelState
, treeReload :: R.State Int
, treeReload :: ReloadS
)
sidebar :: Record Props -> R.Element
......@@ -204,7 +204,7 @@ type DeleteNodes =
, nodes :: Array (Record SigmaxT.Node)
, session :: Session
, termList :: TermList
, treeReload :: R.State Int
, treeReload :: ReloadS
)
deleteNodes :: Record DeleteNodes -> Effect Unit
......
......@@ -43,7 +43,7 @@ import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table as T
import Gargantext.Routes (SessionRoute(..)) as R
import Gargantext.Sessions (Session, get)
import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermList(..), TermSize, termLists, termSizes)
import Gargantext.Types (CTabNgramType, OrderBy(..), ReloadS, SearchQuery, TabType, TermList(..), TermSize, termLists, termSizes)
import Gargantext.Utils (queryMatchesLabel, toggleSet, sortWith)
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.Reactix as R2
......@@ -280,13 +280,13 @@ tableContainerCpt { dispatch
-- NEXT
type Props = (
appReload :: R.State Int
appReload :: ReloadS
, afterSync :: Unit -> Aff Unit
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, path :: R.State PageParams
, state :: R.State State
, tabNgramType :: CTabNgramType
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, treeReloadRef :: R.Ref (Maybe ReloadS)
, versioned :: VersionedNgramsTable
, withAutoUpdate :: Boolean
)
......@@ -510,7 +510,7 @@ selectNgramsOnFirstPage rows = Set.fromFoldable $ (view $ _NgramsElement <<< _ng
type MainNgramsTableProps = (
afterSync :: Unit -> Aff Unit
, appReload :: R.State Int
, appReload :: ReloadS
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NT.CacheState
, defaultListId :: Int
......@@ -520,7 +520,7 @@ type MainNgramsTableProps = (
, session :: Session
, tabNgramType :: CTabNgramType
, tabType :: TabType
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, treeReloadRef :: R.Ref (Maybe ReloadS)
, withAutoUpdate :: Boolean
)
......@@ -620,11 +620,11 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
type MainNgramsTablePaintProps = (
afterSync :: Unit -> Aff Unit
, appReload :: R.State Int
, appReload :: ReloadS
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, path :: PageParams
, tabNgramType :: CTabNgramType
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, treeReloadRef :: R.Ref (Maybe ReloadS)
, versioned :: VersionedNgramsTable
, withAutoUpdate :: Boolean
)
......@@ -653,11 +653,11 @@ mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTable
type MainNgramsTablePaintNoCacheProps = (
afterSync :: Unit -> Aff Unit
, appReload :: R.State Int
, appReload :: ReloadS
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, pathS :: R.State PageParams
, tabNgramType :: CTabNgramType
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, treeReloadRef :: R.Ref (Maybe ReloadS)
, versioned :: VersionedNgramsTable
, withAutoUpdate :: Boolean
)
......
......@@ -25,7 +25,7 @@ import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Unit, bind, const, discard, pure, show, unit, ($), (+), (<$>), (<<<), (<>), (==))
import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, get, put, sessionId)
import Gargantext.Types (NodeType(..))
import Gargantext.Types (NodeType(..), ReloadS)
thisModule :: String
thisModule = "Gargantext.Components.Nodes.Annuaire.User.Contacts"
......@@ -145,12 +145,12 @@ infoRender (Tuple title content) =
, H.span {} [H.text content] ]
type LayoutProps = (
appReload :: R.State Int
appReload :: ReloadS
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, frontends :: Frontends
, nodeId :: Int
, session :: Session
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, treeReloadRef :: R.Ref (Maybe ReloadS)
)
type KeyLayoutProps = (
......@@ -204,7 +204,7 @@ userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey"
}
]
where
onUpdateHyperdata :: R.State Int -> HyperdataUser -> Effect Unit
onUpdateHyperdata :: ReloadS -> HyperdataUser -> Effect Unit
onUpdateHyperdata (_ /\ setReload) hd = do
log2 "[onUpdateHyperdata] hd" hd
launchAff_ $ do
......
......@@ -18,7 +18,7 @@ import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (ContactData)
import Gargantext.Components.Nodes.Lists.Types as NTypes
import Gargantext.Ends (Frontends)
import Gargantext.Sessions (Session)
import Gargantext.Types (TabType(..), TabSubType(..), CTabNgramType(..), PTabNgramType(..))
import Gargantext.Types (ReloadS, TabType(..), TabSubType(..), CTabNgramType(..), PTabNgramType(..))
thisModule :: String
thisModule = "Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs"
......@@ -45,14 +45,14 @@ modeTabType' Books = CTabAuthors
modeTabType' Communication = CTabAuthors
type TabsProps = (
appReload :: R.State Int
appReload :: ReloadS
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NTypes.CacheState
, contactData :: ContactData
, frontends :: Frontends
, nodeId :: Int
, session :: Session
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, treeReloadRef :: R.Ref (Maybe ReloadS)
)
tabs :: Record TabsProps -> R.Element
......@@ -94,14 +94,14 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
type NgramsViewTabsProps = (
appReload :: R.State Int
appReload :: ReloadS
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NTypes.CacheState
, defaultListId :: Int
, mode :: Mode
, nodeId :: Int
, session :: Session
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, treeReloadRef :: R.Ref (Maybe ReloadS)
)
ngramsView :: Record NgramsViewTabsProps -> R.Element
......
......@@ -26,7 +26,7 @@ import Gargantext.Data.Array as GDA
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes (SessionRoute(NodeAPI, Children))
import Gargantext.Sessions (Session, get, put, sessionId)
import Gargantext.Types (NodeType(..), AffTableResult)
import Gargantext.Types (NodeType(..), AffTableResult, ReloadS)
import Gargantext.Utils.Crypto as Crypto
import Gargantext.Utils.Reactix as R2
......@@ -38,8 +38,6 @@ type Props =
, session :: Session
)
type Reload = R.State Int
type KeyProps =
( key :: String
| Props
......@@ -71,7 +69,7 @@ corpusLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "corpusLayoutWith
type ViewProps =
( corpus :: NodePoly Hyperdata
, reload :: Reload
, reload :: ReloadS
| Props
)
......@@ -124,9 +122,9 @@ corpusLayoutViewCpt = R.hooksComponentWithModule thisModule "corpusLayoutView" c
saveEnabled fs (fsS /\ _) = if fs == fsS then "disabled" else "enabled"
onClickSave :: forall e. { fields :: R.State FTFieldsWithIndex
, nodeId :: Int
, reload :: R.State Int
, session :: Session } -> e -> Effect Unit
, nodeId :: Int
, reload :: ReloadS
, session :: Session } -> e -> Effect Unit
onClickSave {fields: (fieldsS /\ _), nodeId, reload: (_ /\ setReload), session} _ = do
log2 "[corpusLayoutViewCpt] onClickSave fieldsS" fieldsS
launchAff_ do
......@@ -175,12 +173,12 @@ fieldsCodeEditorCpt = R.hooksComponentWithModule thisModule "fieldsCodeEditorCpt
fromMaybe fields $
List.modifyAt idx (\(Tuple _ (Field f)) -> Tuple idx (Field $ f { typ = typ })) fields
onMoveDown :: R.State Int -> R.State FTFieldsWithIndex -> Index -> Unit -> Effect Unit
onMoveDown :: ReloadS -> R.State FTFieldsWithIndex -> Index -> Unit -> Effect Unit
onMoveDown (_ /\ setMasterKey) (fs /\ setFields) idx _ = do
setMasterKey $ (+) 1
setFields $ recomputeIndices <<< (GDA.swapList idx (idx + 1))
onMoveUp :: R.State Int -> R.State FTFieldsWithIndex -> Index -> Unit -> Effect Unit
onMoveUp :: ReloadS -> R.State FTFieldsWithIndex -> Index -> Unit -> Effect Unit
onMoveUp (_ /\ setMasterKey) (_ /\ setFields) idx _ = do
setMasterKey $ (+) 1
setFields $ recomputeIndices <<< (GDA.swapList idx (idx - 1))
......
......@@ -5,7 +5,7 @@ import Data.Tuple (Tuple)
import Reactix as R
import Gargantext.Sessions (Session)
import Gargantext.Types (TabType)
import Gargantext.Types (ReloadS, TabType)
type Reload = Int
......@@ -22,7 +22,7 @@ type Props = (
)
type MetricsProps = (
reload :: R.State Int
reload :: ReloadS
| Props
)
......
......@@ -18,13 +18,13 @@ import Gargantext.Utils.Reactix as R2
thisModule = "Gargantext.Components.Nodes.Corpus.Chart.Utils"
reloadButtonWrap :: R.State Int -> R.Element -> R.Element
reloadButtonWrap :: T.ReloadS -> R.Element -> R.Element
reloadButtonWrap setReload el = H.div {} [
reloadButton setReload
, el
]
reloadButton :: R.State Int -> R.Element
reloadButton :: T.ReloadS -> R.Element
reloadButton (_ /\ setReload) = H.a { className
, on: { click: onClick }
, title: "Reload" } []
......@@ -44,7 +44,7 @@ mNgramsTypeFromTabType (T.TabPairing _) = Nothing
type ChartUpdateButtonProps = (
chartType :: T.ChartType
, path :: Record Path
, reload :: R.State Int
, reload :: T.ReloadS
, session :: Session
)
......
......@@ -16,7 +16,7 @@ import Gargantext.Components.Nodes.Dashboard.Types as DT
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude
import Gargantext.Sessions (Session, sessionId)
import Gargantext.Types (NodeID)
import Gargantext.Types (NodeID, ReloadS)
import Gargantext.Utils.Reactix as R2
thisModule = "Gargantext.Components.Nodes.Corpus.Dashboard"
......@@ -63,7 +63,7 @@ dashboardLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "dashboardLayo
, session }
where
onChange :: NodeID -> R.State Int -> DT.Hyperdata -> Array P.PredefinedChart -> Effect Unit
onChange :: NodeID -> ReloadS -> DT.Hyperdata -> Array P.PredefinedChart -> Effect Unit
onChange nodeId' (_ /\ setReload) (DT.Hyperdata h) charts = do
launchAff_ do
DT.saveDashboard { hyperdata: DT.Hyperdata $ h { charts = charts }
......
......@@ -16,7 +16,7 @@ import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Sessions (Session, get, sessionId)
import Gargantext.Types (NodeType(..))
import Gargantext.Types (NodeType(..), ReloadS)
import Gargantext.Utils.Argonaut (genericSumEncodeJson)
import Gargantext.Utils.Reactix as R2
......@@ -54,8 +54,6 @@ type Props =
, nodeType :: NodeType
)
type Reload = R.State Int
type KeyProps =
( key :: String
| Props
......@@ -86,7 +84,7 @@ frameLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "frameLayoutWithKe
type ViewProps =
( frame :: NodePoly Hyperdata
, reload :: Reload
, reload :: ReloadS
| Props
)
......
......@@ -18,6 +18,7 @@ import Gargantext.Components.Table as Table
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude
import Gargantext.Sessions (Session, sessionId, getCacheState, setCacheState)
import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2
thisModule :: String
......@@ -26,12 +27,12 @@ thisModule = "Gargantext.Components.Nodes.Lists"
------------------------------------------------------------------------
type Props = (
appReload :: R.State Int
appReload :: GT.ReloadS
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, nodeId :: Int
, session :: Session
, sessionUpdate :: Session -> Effect Unit
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, treeReloadRef :: R.Ref (Maybe GT.ReloadS)
)
listsLayout :: Record Props -> R.Element
......
......@@ -23,20 +23,20 @@ import Gargantext.Components.Nodes.Corpus.Chart.Utils (mNgramsTypeFromTabType)
import Gargantext.Components.Nodes.Lists.Types as NTypes
import Gargantext.Components.Tab as Tab
import Gargantext.Sessions (Session)
import Gargantext.Types (ChartType(..), CTabNgramType(..), Mode(..), TabSubType(..), TabType(..), chartTypeFromString, modeTabType)
import Gargantext.Types (ChartType(..), CTabNgramType(..), Mode(..), ReloadS, TabSubType(..), TabType(..), chartTypeFromString, modeTabType)
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Nodes.Lists.Tabs"
type Props = (
appReload :: R.State Int
appReload :: ReloadS
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NTypes.CacheState
, corpusData :: CorpusData
, corpusId :: Int
, session :: Session
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, treeReloadRef :: R.Ref (Maybe ReloadS)
)
type PropsWithKey = (
......
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