From d8ddec6177fffc04643daa630457e1f536e7060a Mon Sep 17 00:00:00 2001 From: nklhrstv Date: Fri, 6 Mar 2020 16:49:36 +0200 Subject: [PATCH] MuteButton validation improved --- src/routes/Player/ControlBar/MuteButton/MuteButton.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/routes/Player/ControlBar/MuteButton/MuteButton.js b/src/routes/Player/ControlBar/MuteButton/MuteButton.js index 0573f50bf..3f6076837 100644 --- a/src/routes/Player/ControlBar/MuteButton/MuteButton.js +++ b/src/routes/Player/ControlBar/MuteButton/MuteButton.js @@ -6,9 +6,11 @@ const { Button } = require('stremio/common'); const MuteButton = ({ className, muted, volume, dispatch }) => { const toggleMuted = React.useCallback(() => { - dispatch({ propName: 'muted', propValue: !muted }); + if (typeof dispatch === 'function') { + dispatch({ propName: 'muted', propValue: !muted }); + } }, [muted, dispatch]); - const icon = muted ? 'ic_volume0' : + const icon = (typeof muted === 'boolean' && muted) ? 'ic_volume0' : (volume === null || isNaN(volume)) ? 'ic_volume3' : volume < 30 ? 'ic_volume1' : volume < 70 ? 'ic_volume2' : @@ -18,7 +20,7 @@ const MuteButton = ({ className, muted, volume, dispatch }) => { ); -} +}; MuteButton.propTypes = { className: PropTypes.string,