From b909f32d572cd66f48475ee234a4a69c89402149 Mon Sep 17 00:00:00 2001 From: Stian Aune Date: Sat, 9 Nov 2019 23:41:47 +0100 Subject: [PATCH] Fixed. --- my-bois/src/components/Bois.jsx | 12 ++++++++++++ my-bois/src/components/Contexts.jsx | 2 ++ 2 files changed, 14 insertions(+) diff --git a/my-bois/src/components/Bois.jsx b/my-bois/src/components/Bois.jsx index 1d80c72..a1af919 100644 --- a/my-bois/src/components/Bois.jsx +++ b/my-bois/src/components/Bois.jsx @@ -41,6 +41,7 @@ export const CentreBoi = () => { const { state, program, setProgram, bike, setBike, bikes, programs, start, pause, stop, create, workoutStatus, + hidden, setHidden, } = useContext(StatusContext); const [options, setOptions] = useState(null); const [current, setCurrent] = useState(0); @@ -112,6 +113,17 @@ export const CentreBoi = () => { } }); + useKey("H", () => showHide()); + useKey("h", () => showHide()); + + function showHide() { + setHidden(!hidden); + } + + if (hidden) { + return null; + } + if (state === "started" && workoutStatus !== null) { const {minutes, seconds, calories} = workoutStatus; const diff = calculateDiff(program, minutes, seconds, calories); diff --git a/my-bois/src/components/Contexts.jsx b/my-bois/src/components/Contexts.jsx index 98a43ba..79f5c42 100644 --- a/my-bois/src/components/Contexts.jsx +++ b/my-bois/src/components/Contexts.jsx @@ -37,6 +37,7 @@ export const StatusContextProvider = ({children}) => { const [state, setState] = useState("offline"); const {milestones, prevDiff, prevLongDiff, msDispatch} = useMilestones(); const [socket, setSocket] = useState(null); + const [hidden, setHidden] = useState(false); useEffect(() => { if (programs === null) { @@ -161,6 +162,7 @@ export const StatusContextProvider = ({children}) => { setBike, setProgram, create, resume, start, pause, stop, programs, bikes, + hidden, setHidden, }}> {children}