From 31ce7e010d85c1509bb4443e9c30969e312ffc07 Mon Sep 17 00:00:00 2001 From: robertpin Date: Mon, 4 Oct 2021 11:37:02 +0300 Subject: [PATCH] fix(config, reactions) Added config option to disable reaction sounds (#10046) --- config.js | 1 + react/features/base/sounds/actions.js | 2 +- react/features/reactions/constants.js | 17 +++++++++++------ react/features/reactions/middleware.js | 13 +++++++++++-- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/config.js b/config.js index 910f1f966..2dffdc14a 100644 --- a/config.js +++ b/config.js @@ -772,6 +772,7 @@ var config = { // - 'PARTICIPANT_JOINED_SOUND' // - 'PARTICIPANT_LEFT_SOUND' // - 'RAISE_HAND_SOUND' + // - 'REACTION_SOUND' // - 'RECORDING_OFF_SOUND' // - 'RECORDING_ON_SOUND' // - 'TALK_WHILE_MUTED_SOUND' diff --git a/react/features/base/sounds/actions.js b/react/features/base/sounds/actions.js index bd9d9071e..4584bc575 100644 --- a/react/features/base/sounds/actions.js +++ b/react/features/base/sounds/actions.js @@ -70,7 +70,7 @@ export function playSound(soundId: string): Object { return (dispatch: Function, getState: Function) => { const disabledSounds = getDisabledSounds(getState()); - if (!disabledSounds.includes(soundId)) { + if (!disabledSounds.includes(soundId) && !disabledSounds.find(id => soundId.startsWith(id))) { dispatch({ type: PLAY_SOUND, soundId diff --git a/react/features/reactions/constants.js b/react/features/reactions/constants.js index 266dbdac9..5f0c3fd19 100644 --- a/react/features/reactions/constants.js +++ b/react/features/reactions/constants.js @@ -14,13 +14,18 @@ import { */ export const ENDPOINT_REACTION_NAME = 'endpoint-reaction'; +/** + * The prefix for all reaction sound IDs. Also the ID used in config to disable reaction sounds. + */ +export const REACTION_SOUND = 'REACTION_SOUND'; + /** * The audio ID prefix of the audio element for which the {@link playAudio} action is * triggered when a new laugh reaction is received. * * @type { string } */ -export const LAUGH_SOUND_ID = 'LAUGH_SOUND_'; +export const LAUGH_SOUND_ID = `${REACTION_SOUND}_LAUGH_`; /** * The audio ID prefix of the audio element for which the {@link playAudio} action is @@ -28,7 +33,7 @@ export const LAUGH_SOUND_ID = 'LAUGH_SOUND_'; * * @type {string} */ -export const CLAP_SOUND_ID = 'CLAP_SOUND_'; +export const CLAP_SOUND_ID = `${REACTION_SOUND}_CLAP_`; /** * The audio ID prefix of the audio element for which the {@link playAudio} action is @@ -36,7 +41,7 @@ export const CLAP_SOUND_ID = 'CLAP_SOUND_'; * * @type {string} */ -export const LIKE_SOUND_ID = 'LIKE_SOUND_'; +export const LIKE_SOUND_ID = `${REACTION_SOUND}_LIKE_`; /** * The audio ID prefix of the audio element for which the {@link playAudio} action is @@ -44,7 +49,7 @@ export const LIKE_SOUND_ID = 'LIKE_SOUND_'; * * @type {string} */ -export const BOO_SOUND_ID = 'BOO_SOUND_'; +export const BOO_SOUND_ID = `${REACTION_SOUND}_BOO_`; /** * The audio ID prefix of the audio element for which the {@link playAudio} action is @@ -52,7 +57,7 @@ export const BOO_SOUND_ID = 'BOO_SOUND_'; * * @type {string} */ -export const SURPRISE_SOUND_ID = 'SURPRISE_SOUND_'; +export const SURPRISE_SOUND_ID = `${REACTION_SOUND}_SURPRISE_`; /** * The audio ID prefix of the audio element for which the {@link playAudio} action is @@ -60,7 +65,7 @@ export const SURPRISE_SOUND_ID = 'SURPRISE_SOUND_'; * * @type {string} */ -export const SILENCE_SOUND_ID = 'SILENCE_SOUND_'; +export const SILENCE_SOUND_ID = `${REACTION_SOUND}_SILENCE_`; /** * The audio ID of the audio element for which the {@link playAudio} action is diff --git a/react/features/reactions/middleware.js b/react/features/reactions/middleware.js index 01eb2b40b..e34a7036c 100644 --- a/react/features/reactions/middleware.js +++ b/react/features/reactions/middleware.js @@ -7,6 +7,7 @@ import { getParticipantCount } from '../base/participants'; import { MiddlewareRegistry } from '../base/redux'; import { updateSettings } from '../base/settings'; import { playSound, registerSound, unregisterSound } from '../base/sounds'; +import { getDisabledSounds } from '../base/sounds/functions.any'; import { isVpaasMeeting } from '../jaas/functions'; import { NOTIFICATION_TIMEOUT, showNotification } from '../notifications'; @@ -25,7 +26,13 @@ import { sendReactions, setReactionQueue } from './actions.any'; -import { ENDPOINT_REACTION_NAME, RAISE_HAND_SOUND_ID, REACTIONS, SOUNDS_THRESHOLDS } from './constants'; +import { + ENDPOINT_REACTION_NAME, + RAISE_HAND_SOUND_ID, + REACTIONS, + REACTION_SOUND, + SOUNDS_THRESHOLDS +} from './constants'; import { getReactionMessageFromBuffer, getReactionsSoundsThresholds, @@ -128,10 +135,12 @@ MiddlewareRegistry.register(store => next => action => { const state = getState(); const { queue, notificationDisplayed } = state['features/reactions']; const { soundsReactions } = state['features/base/settings']; + const disabledSounds = getDisabledSounds(state); const reactions = action.reactions; batch(() => { - if (!notificationDisplayed && soundsReactions && displayReactionSoundsNotification) { + if (!notificationDisplayed && soundsReactions && !disabledSounds.includes(REACTION_SOUND) + && displayReactionSoundsNotification) { dispatch(displayReactionSoundsNotification()); } if (soundsReactions) {