Simplify reaction sounds

This commit is contained in:
Half-Shot
2024-12-03 14:46:06 +00:00
parent 0c331a05ad
commit 2a45be88e9
2 changed files with 8 additions and 13 deletions

View File

@@ -72,8 +72,8 @@ export function CallEventAudioRenderer({
({ joined, ids }) =>
ids.length <= MAX_PARTICIPANT_COUNT_FOR_SOUND && joined.length > 0,
),
throttle((_) => interval(THROTTLE_SOUND_EFFECT_MS)),
debounce((_) => interval(DEBOUNCE_SOUND_EFFECT_MS)),
throttle(() => interval(THROTTLE_SOUND_EFFECT_MS)),
debounce(() => interval(DEBOUNCE_SOUND_EFFECT_MS)),
)
.subscribe((prev) => {
console.log("Playing join sound for", ...prev.joined, "|", prev);
@@ -86,8 +86,8 @@ export function CallEventAudioRenderer({
({ ids, left }) =>
ids.length <= MAX_PARTICIPANT_COUNT_FOR_SOUND && left.length > 0,
),
throttle((_) => interval(THROTTLE_SOUND_EFFECT_MS)),
debounce((_) => interval(DEBOUNCE_SOUND_EFFECT_MS)),
throttle(() => interval(THROTTLE_SOUND_EFFECT_MS)),
debounce(() => interval(DEBOUNCE_SOUND_EFFECT_MS)),
)
.subscribe(() => {
audioEngineCtx.playSound("left");

View File

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