From 0e2946e4e60ab7ddcd9a8192e6863e0d086a5c14 Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Thu, 9 Feb 2023 10:56:25 -0500 Subject: [PATCH] cleanup --- js/tree.js | 108 +++++++++++++++++++++-------------------------------- 1 file changed, 42 insertions(+), 66 deletions(-) diff --git a/js/tree.js b/js/tree.js index 1195e8e..1a2ddfe 100644 --- a/js/tree.js +++ b/js/tree.js @@ -21,6 +21,7 @@ export const Branch = (props) => { React.useEffect(() => { const [{ Open, Done, Away }] = stageParent; const [, Shut] = stage; + if (!Open && Done) { Shut({ Open: false, Done: true, Away }); } @@ -37,33 +38,12 @@ export const Button = (props) => { /** @type Binding */ const [stageGet, stageSet] = React.useContext(BranchContext); - /** @type React.MutableRefObject */ - const refHandler = React.useRef(null); - React.useEffect(() => { - console.log("recreating handler", stageGet); - refHandler.current = (away) => { - console.log("set: away"); - stageSet((state) => ({ ...state, Away: away })); - }; - }, [stageGet]); - - /** @type React.MutableRefObject */ - const refEl = React.useRef(null); - useAway(refEl, refHandler); - const handleClick = () => { console.log("set: open"); stageSet((state) => ({ ...state, Open: !state.Open, Done: false })); }; - React.useEffect(() => { - console.log("away *changed*"); - if (stageGet.Away && stageGet.Open) { - handleClick(); - } - }, [stageGet.Away]); - - return html`