From 26382e0991eaf6546fd2c7e1dcb35c0f83f4c2a6 Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Mon, 27 Jun 2022 13:26:38 -0700 Subject: [PATCH] Persist volume setting in localStorage Signed-off-by: James Ketrenos --- client/src/App.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/src/App.js b/client/src/App.js index 5afa60f..a93fbae 100755 --- a/client/src/App.js +++ b/client/src/App.js @@ -84,7 +84,9 @@ const Table = () => { const [winnerDismissed, setWinnerDismissed] = useState(undefined); const [global, setGlobal] = useState({}); const [count, setCount] = useState(0); - const [volume, setVolume] = useState(0.5); + const [volume, setVolume] = useState( + localStorage.getItem('volume') ? + parseFloat(localStorage.getItem('volume')) : 0.5); const fields = [ 'id', 'state', 'color', 'name', 'private', 'dice', 'turn' ]; const onWsOpen = (event) => { @@ -483,6 +485,7 @@ const Table = () => { min="0" max="100" onInput={(e) => { const alpha = e.currentTarget.value / 100; + localStorage.setItem('volume', alpha); setVolume(alpha); }}/> }