diff --git a/src/components/client/reset.ts b/src/components/client/reset.ts index 904b82f80..7fae88a47 100644 --- a/src/components/client/reset.ts +++ b/src/components/client/reset.ts @@ -19,6 +19,9 @@ const ResetCache: React.FC<{ }> = ({clientId, reset, station}) => { const client = useApolloClient(); const {playSound, removeAllSounds} = useSounds(); + const excludeStation = + (station?.name && excludedStations.includes(station?.name)) || + station?.cards.find(c => excludedStations.indexOf(c.component) > -1); React.useEffect(() => { const cacheSub = client @@ -32,11 +35,7 @@ const ResetCache: React.FC<{ next: () => { // Reset all of the sounds that are currently playing removeAllSounds(); - if ( - (station?.name && excludedStations.includes(station?.name)) || - station?.cards.find(c => excludedStations.indexOf(c.component) > -1) - ) - return; + if (excludeStation) return; playSound({url: "/sciences.ogg"}); reset?.(); publish("widgetClose"); @@ -48,7 +47,7 @@ const ResetCache: React.FC<{ return () => { cacheSub.unsubscribe(); }; - }, [client, clientId, playSound, removeAllSounds, reset, station]); + }, [client, clientId, excludeStation, playSound, removeAllSounds, reset]); return null; }; diff --git a/src/components/client/soundPlayer.tsx b/src/components/client/soundPlayer.tsx index 10a37a28c..45b83c3ef 100644 --- a/src/components/client/soundPlayer.tsx +++ b/src/components/client/soundPlayer.tsx @@ -34,25 +34,11 @@ const SoundPlayer: React.FC<{ }; }, [client, playSound, removeAllSounds, simulator.id]); - if (invisible) - return ( - { - removeAllSounds(); - }} - /> - ); + const station = React.useMemo(() => ({name: "Sound", cards: []}), []); + if (invisible) return ; return (
- { - removeAllSounds(); - }} - /> +