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