[ws] fix refreshing of a pinned tree

parent cb9a6dd5
Pipeline #6803 passed with stages
in 13 minutes and 47 seconds
......@@ -126,12 +126,13 @@ treeLoaderCpt = R2.hereComponent here "treeLoader" hCpt where
-- app <- T.useLive T.unequal p.reloadRoot
state /\ stateBox <- R2.useBox' Nothing
let fetch { root: r } = getNodeTree session r
reload' <- T.useLive T.unequal p.reload
-- Hooks
useLoaderEffect
{ errorHandler
, loader: fetch
, path: { root }
, path: { root, reload: reload' }
, state: stateBox
}
......@@ -174,6 +175,20 @@ treeCpt = here.component "tree" cpt where
folderOpen <- useOpenNodesMemberBox nodeId forestOpen
folderOpen' <- T.useLive T.unequal folderOpen
R.useEffectOnce' $ do
-- We set up notifications listener here. 'tree' is only a
-- component for the root of the tree, other subtrees are
-- rendered via 'childLoader'. However, we still need a hook
-- here, so that if e.g. the tree is pinned, it becomes its own
-- root and we want to see notifications of it as well.
let cb _ = do
here.log2 "[tree] callback!" root
-- The modal window has some problems closing when we refresh too early. This is a HACK
void $ setTimeout 400 $ T2.reload reload
let action = NotificationsT.InsertCallback (NotificationsT.UpdateTree root) ("tree-" <> show root) cb
ws <- T.read boxes.wsNotification
Notifications.performAction ws action
R.useEffect' do
selectedLeaf <- R2.querySelector ".mainleaf--selected"
case selectedLeaf of
......@@ -323,11 +338,10 @@ childLoaderCpt = R2.hereComponent here "childLoader" hCpt where
boxes <- Store.use
R.useEffectOnce' $ do
let cb _ = do
here.log2 "callback!" p.id
here.log2 "[childLoader] callback!" p.id
-- The modal window has some problems closing when we refresh too early. This is a HACK
void $ setTimeout 400 $ T2.reload reload
let action = NotificationsT.InsertCallback (NotificationsT.UpdateTree p.id) ("tree-" <> show p.id) cb
here.log2 "[childLoader] action" action
ws <- T.read boxes.wsNotification
Notifications.performAction ws action
......
......@@ -327,8 +327,8 @@ nodeSpanCpt = here.component "nodeSpan" cpt
{ name: "thumb-tack-inclined"
, className: "mainleaf__pin-icon"
, callback: \_ -> do
log2 "[Pinning tree ID]" id
T.modify_ (Map.insert (show session) id) boxes.pinnedTreeId
log2 "[Pinning tree ID]" id
T.modify_ (Map.insert (show session) id) boxes.pinnedTreeId
, title: "Pin the tree to this node"
, variant: Secondary
, elevation: Level1
......
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