only play one sound per reaction type

This commit is contained in:
Half-Shot
2024-12-03 14:47:01 +00:00
parent 2a45be88e9
commit 4d5a543330

View File

@@ -38,13 +38,18 @@ export function ReactionsAudioRenderer(): ReactNode {
if (!shouldPlay) { if (!shouldPlay) {
return; return;
} }
for (const [sender, reaction] of Object.entries(reactions)) { const oldReactionSet = new Set(
if (oldReactions[sender]) { Object.values(oldReactions).map((r) => r.name),
);
for (const reactionName of new Set(
Object.values(reactions).map((r) => r.name),
)) {
if (oldReactionSet.has(reactionName)) {
// Don't replay old reactions // Don't replay old reactions
return; return;
} }
if (SoundMap[reaction.name]) { if (SoundMap[reactionName]) {
audioEngineCtx.playSound(reaction.name); audioEngineCtx.playSound(reactionName);
} else { } else {
// Fallback sounds. // Fallback sounds.
audioEngineCtx.playSound("generic"); audioEngineCtx.playSound("generic");