From 486aa11e73a06096fccacf67af3debe55ad45a83 Mon Sep 17 00:00:00 2001 From: stian Date: Wed, 20 May 2020 06:18:11 +0000 Subject: [PATCH 1/2] Pause and retroactively start cooldown. --- my-bois/src/components/Contexts.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/my-bois/src/components/Contexts.jsx b/my-bois/src/components/Contexts.jsx index 1a5df6a..101b590 100644 --- a/my-bois/src/components/Contexts.jsx +++ b/my-bois/src/components/Contexts.jsx @@ -51,9 +51,13 @@ export const StatusContextProvider = ({children}) => { if (cooldownMin === -1) { setWorkout(await updateCooldownMins(workout, minutes + 1)); } else if (minutes < cooldownMin) { + if (state === "connected") { + setWorkout(await updateCooldownMins(workout, minutes)); + } + setWorkout(await updateCooldownMins(workout, -1)); } - }, [workout, workoutStatus]); + }, [workout, workoutStatus, state]); useEffect(() => { if (bikes !== null && bikes.length === 1) { From 41ca13af8adbdcf154696b456707e2874192735e Mon Sep 17 00:00:00 2001 From: Stian Fredrik Aune Date: Wed, 20 May 2020 13:21:42 +0200 Subject: [PATCH 2/2] Stuffety-stuff --- my-bois/src/components/Bois.jsx | 2 +- my-bois/src/components/Contexts.jsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/my-bois/src/components/Bois.jsx b/my-bois/src/components/Bois.jsx index e98cd07..9ccca94 100644 --- a/my-bois/src/components/Bois.jsx +++ b/my-bois/src/components/Bois.jsx @@ -120,7 +120,7 @@ export const CentreBoi = () => { useKey(["H", "h"], () => showHide()); useKey("*", () => { - if (state === "started") { + if (state === "started" || state === "connected") { toggleCooldown(); } }); diff --git a/my-bois/src/components/Contexts.jsx b/my-bois/src/components/Contexts.jsx index 101b590..555e099 100644 --- a/my-bois/src/components/Contexts.jsx +++ b/my-bois/src/components/Contexts.jsx @@ -53,9 +53,9 @@ export const StatusContextProvider = ({children}) => { } else if (minutes < cooldownMin) { if (state === "connected") { setWorkout(await updateCooldownMins(workout, minutes)); - } - - setWorkout(await updateCooldownMins(workout, -1)); + } else { + setWorkout(await updateCooldownMins(workout, -1)); + } } }, [workout, workoutStatus, state]);