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`