Skip to content

Commit

Permalink
Fix sound & mic state update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Tinland committed Dec 24, 2023
1 parent 73d6595 commit 93c901f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/components/data/mic.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <DataWidgetLoader.Widget className="mic" />;
if (!state || volume === undefined || _volume === "missing value")
Expand Down
1 change: 1 addition & 0 deletions lib/components/data/sound.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const Widget = React.memo(() => {
if (_volume && currentVolume !== parseInt(_volume, 10)) {
return parseInt(_volume, 10);
}
return currentVolume;
});
}, [_volume]);

Expand Down

0 comments on commit 93c901f

Please sign in to comment.