Commit 21533aa5 authored by James Laver's avatar James Laver

do the context bypass

parent 0f030aae
...@@ -147,7 +147,7 @@ type KeyLayoutProps = ( key :: String, session :: Session | ReloadProps ) ...@@ -147,7 +147,7 @@ type KeyLayoutProps = ( key :: String, session :: Session | ReloadProps )
saveContactHyperdata :: Session -> Int -> HyperdataContact -> Aff Int saveContactHyperdata :: Session -> Int -> HyperdataContact -> Aff Int
saveContactHyperdata session id = put session (Routes.NodeAPI Node (Just id) "") saveContactHyperdata session id = put session (Routes.NodeAPI Node (Just id) "")
type AnnuaireLayoutProps = ( annuaireId :: Int, session :: Session | ReloadProps ) type AnnuaireLayoutProps = ( annuaireId :: Int, session :: R.Context Session | ReloadProps )
type AnnuaireKeyLayoutProps = ( annuaireId :: Int | KeyLayoutProps ) type AnnuaireKeyLayoutProps = ( annuaireId :: Int | KeyLayoutProps )
...@@ -157,11 +157,12 @@ contactLayout = R.createElement contactLayoutCpt ...@@ -157,11 +157,12 @@ contactLayout = R.createElement contactLayoutCpt
contactLayoutCpt :: R.Component AnnuaireLayoutProps contactLayoutCpt :: R.Component AnnuaireLayoutProps
contactLayoutCpt = here.component "contactLayout" cpt where contactLayoutCpt = here.component "contactLayout" cpt where
cpt { annuaireId, frontends, nodeId, reloadForest, reloadRoot, session, tasks } _ = do cpt { annuaireId, frontends, nodeId, reloadForest, reloadRoot, session, tasks } _ = do
s <- R.useContext session
let key = show (sessionId s) <> "-" <> show nodeId
pure $ pure $
contactLayoutWithKey contactLayoutWithKey
{ annuaireId, tasks, frontends, key, nodeId { annuaireId, tasks, frontends, key, nodeId
, session, reloadForest, reloadRoot } , session: s, reloadForest, reloadRoot }
where key = show (sessionId session) <> "-" <> show nodeId
contactLayoutWithKey :: R2.Leaf AnnuaireKeyLayoutProps contactLayoutWithKey :: R2.Leaf AnnuaireKeyLayoutProps
contactLayoutWithKey props = R.createElement contactLayoutWithKeyCpt props [] contactLayoutWithKey props = R.createElement contactLayoutWithKeyCpt props []
......
...@@ -49,7 +49,7 @@ type Props = ( ...@@ -49,7 +49,7 @@ type Props = (
) )
type SessionProps = ( type SessionProps = (
session :: Session session :: R.Context Session
, sessionId :: SessionId , sessionId :: SessionId
| Props | Props
) )
...@@ -115,32 +115,31 @@ forestedCpt = here.component "forested" cpt ...@@ -115,32 +115,31 @@ forestedCpt = here.component "forested" cpt
authed :: Record SessionProps -> R.Element -> R.Element authed :: Record SessionProps -> R.Element -> R.Element
authed props@{ cursors: { sessions }, session, sessionId, tasks } content = authed props@{ cursors: { sessions }, session, sessionId, tasks } content =
sessionWrapper { fallback: home homeProps [], provider: session, sessionId, sessions } sessionWrapper { fallback: home homeProps [], context: session, sessionId, sessions }
[ content, footer { } [] ] [ content, footer { } [] ]
where where
homeProps = RE.pick props :: Record Props homeProps = RE.pick props :: Record Props
annuaire :: R2.Component SessionNodeProps annuaire :: R2.Component SessionNodeProps
annuaire = R.createElement annuaireCpt annuaire = R.createElement annuaireCpt
annuaireCpt :: R.Component SessionNodeProps annuaireCpt :: R.Component SessionNodeProps
annuaireCpt = here.component "annuaire" cpt annuaireCpt = here.component "annuaire" cpt where
where cpt props@{ nodeId, session, sessionId, tasks } _ = do
cpt props@{ nodeId, session, sessionId, tasks } _ = do let sessionProps = RE.pick props :: Record SessionProps
let sessionProps = RE.pick props :: Record SessionProps pure $ authed sessionProps $
pure $ authed sessionProps $ forested props [ annuaireLayout { frontends, nodeId, session } ]
forested props [ annuaireLayout { frontends, nodeId, session } ] where frontends = defaultFrontends
where frontends = defaultFrontends
corpus :: R2.Component SessionNodeProps corpus :: R2.Component SessionNodeProps
corpus = R.createElement corpusCpt corpus = R.createElement corpusCpt
corpusCpt :: R.Component SessionNodeProps corpusCpt :: R.Component SessionNodeProps
corpusCpt = here.component "corpus" cpt corpusCpt = here.component "corpus" cpt where
where cpt props@{ cursors, nodeId, session, tasks } _ = do
cpt props@{ cursors: session, nodeId, session, tasks } _ = do let sessionProps = RE.pick props :: Record SessionProps
let sessionProps = RE.pick props :: Record SessionProps pure $ authed sessionProps $
pure $ authed sessionProps $ forested props [ corpusLayout { nodeId, session } ]
forested props
[ corpusLayout { nodeId, session } ]
type CorpusDocumentProps = ( type CorpusDocumentProps = (
corpusId :: CorpusId corpusId :: CorpusId
......
...@@ -21,7 +21,7 @@ here = R2.here "Gargantext.Components.SessionWrapper" ...@@ -21,7 +21,7 @@ here = R2.here "Gargantext.Components.SessionWrapper"
type Props = type Props =
( (
fallback :: R.Element fallback :: R.Element
, provider :: R.Provider Session , context :: R.Context Session
, sessionId :: SessionId , sessionId :: SessionId
, sessions :: T.Cursor Sessions , sessions :: T.Cursor Sessions
) )
...@@ -31,10 +31,10 @@ sessionWrapper = R.createElement sessionWrapperCpt ...@@ -31,10 +31,10 @@ sessionWrapper = R.createElement sessionWrapperCpt
sessionWrapperCpt :: R.Component Props sessionWrapperCpt :: R.Component Props
sessionWrapperCpt = here.component "sessionWrapper" cpt where sessionWrapperCpt = here.component "sessionWrapper" cpt where
cpt { fallback, provider, sessionId, sessions } content = do cpt { fallback, context, sessionId, sessions } content = do
sessions' <- T.useLive T.unequal sessions sessions' <- T.useLive T.unequal sessions
pure $ cp sessions' pure $ cp sessions'
where where
cp sessions' = c $ Sessions.lookup sessionId sessions' where cp sessions' = c $ Sessions.lookup sessionId sessions' where
c (Just session) = (R.provide provider session content) c (Just session) = (R.provideContext context session content)
c Nothing = fallback c Nothing = fallback
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