From 93c901f05b9d8fca9467ba2cfd855241c6aa7f2c Mon Sep 17 00:00:00 2001 From: Jean Tinland Date: Sun, 24 Dec 2023 08:56:43 +0100 Subject: [PATCH] Fix sound & mic state update --- lib/components/data/mic.jsx | 11 +++++++---- lib/components/data/sound.jsx | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/components/data/mic.jsx b/lib/components/data/mic.jsx index 14b575c0..e70d8b95 100644 --- a/lib/components/data/mic.jsx +++ b/lib/components/data/mic.jsx @@ -56,10 +56,13 @@ export const Widget = React.memo(() => { }, [dragging, volume]); React.useEffect(() => { - if (_volume && parseInt(_volume, 10) !== volume) { - setVolume(parseInt(_volume, 10)); - } - }, [_volume, volume]); + setVolume((currentVolume) => { + if (_volume && currentVolume !== parseInt(_volume, 10)) { + return parseInt(_volume, 10); + } + return currentVolume; + }); + }, [_volume]); if (loading) return ; if (!state || volume === undefined || _volume === "missing value") diff --git a/lib/components/data/sound.jsx b/lib/components/data/sound.jsx index 4c496719..b5bf9e50 100644 --- a/lib/components/data/sound.jsx +++ b/lib/components/data/sound.jsx @@ -68,6 +68,7 @@ export const Widget = React.memo(() => { if (_volume && currentVolume !== parseInt(_volume, 10)) { return parseInt(_volume, 10); } + return currentVolume; }); }, [_volume]);