Fix reaction sound

This commit is contained in:
Half-Shot
2024-12-05 11:04:49 +00:00
parent d8857283bb
commit 0139499e0d

View File

@@ -9,16 +9,17 @@ import { ReactNode, useDeferredValue, useEffect } from "react";
import { useReactions } from "../useReactions"; import { useReactions } from "../useReactions";
import { playReactionsSound, useSetting } from "../settings/settings"; import { playReactionsSound, useSetting } from "../settings/settings";
import { ReactionSet } from "../reactions"; import { GenericReaction, ReactionSet } from "../reactions";
import { prefetchSounds, useAudioContext } from "../useAudioContext"; import { prefetchSounds, useAudioContext } from "../useAudioContext";
import { useLatest } from "../useLatest"; import { useLatest } from "../useLatest";
const SoundMap = Object.fromEntries( const SoundMap = Object.fromEntries([
ReactionSet.filter((v) => v.sound !== undefined).map((v) => [ ...ReactionSet.filter((v) => v.sound !== undefined).map((v) => [
v.name, v.name,
v.sound!, v.sound!,
]), ]),
); [GenericReaction.name, GenericReaction.sound],
]);
const Sounds = prefetchSounds(SoundMap); const Sounds = prefetchSounds(SoundMap);
@@ -50,6 +51,7 @@ export function ReactionsAudioRenderer(): ReactNode {
audioEngineRef.current.playSound(reactionName); audioEngineRef.current.playSound(reactionName);
} else { } else {
// Fallback sounds. // Fallback sounds.
console.log("Playing fallback sound");
audioEngineRef.current.playSound("generic"); audioEngineRef.current.playSound("generic");
} }
} }