fix(config, reactions) Added config option to disable reaction sounds (#10046)

This commit is contained in:
robertpin 2021-10-04 11:37:02 +03:00 committed by GitHub
parent acfc9c6683
commit 31ce7e010d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 9 deletions

View File

@ -772,6 +772,7 @@ var config = {
// - 'PARTICIPANT_JOINED_SOUND' // - 'PARTICIPANT_JOINED_SOUND'
// - 'PARTICIPANT_LEFT_SOUND' // - 'PARTICIPANT_LEFT_SOUND'
// - 'RAISE_HAND_SOUND' // - 'RAISE_HAND_SOUND'
// - 'REACTION_SOUND'
// - 'RECORDING_OFF_SOUND' // - 'RECORDING_OFF_SOUND'
// - 'RECORDING_ON_SOUND' // - 'RECORDING_ON_SOUND'
// - 'TALK_WHILE_MUTED_SOUND' // - 'TALK_WHILE_MUTED_SOUND'

View File

@ -70,7 +70,7 @@ export function playSound(soundId: string): Object {
return (dispatch: Function, getState: Function) => { return (dispatch: Function, getState: Function) => {
const disabledSounds = getDisabledSounds(getState()); const disabledSounds = getDisabledSounds(getState());
if (!disabledSounds.includes(soundId)) { if (!disabledSounds.includes(soundId) && !disabledSounds.find(id => soundId.startsWith(id))) {
dispatch({ dispatch({
type: PLAY_SOUND, type: PLAY_SOUND,
soundId soundId

View File

@ -14,13 +14,18 @@ import {
*/ */
export const ENDPOINT_REACTION_NAME = 'endpoint-reaction'; 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 * The audio ID prefix of the audio element for which the {@link playAudio} action is
* triggered when a new laugh reaction is received. * triggered when a new laugh reaction is received.
* *
* @type { string } * @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 * 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} * @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 * 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} * @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 * 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} * @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 * 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} * @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 * 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} * @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 * The audio ID of the audio element for which the {@link playAudio} action is

View File

@ -7,6 +7,7 @@ import { getParticipantCount } from '../base/participants';
import { MiddlewareRegistry } from '../base/redux'; import { MiddlewareRegistry } from '../base/redux';
import { updateSettings } from '../base/settings'; import { updateSettings } from '../base/settings';
import { playSound, registerSound, unregisterSound } from '../base/sounds'; import { playSound, registerSound, unregisterSound } from '../base/sounds';
import { getDisabledSounds } from '../base/sounds/functions.any';
import { isVpaasMeeting } from '../jaas/functions'; import { isVpaasMeeting } from '../jaas/functions';
import { NOTIFICATION_TIMEOUT, showNotification } from '../notifications'; import { NOTIFICATION_TIMEOUT, showNotification } from '../notifications';
@ -25,7 +26,13 @@ import {
sendReactions, sendReactions,
setReactionQueue setReactionQueue
} from './actions.any'; } 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 { import {
getReactionMessageFromBuffer, getReactionMessageFromBuffer,
getReactionsSoundsThresholds, getReactionsSoundsThresholds,
@ -128,10 +135,12 @@ MiddlewareRegistry.register(store => next => action => {
const state = getState(); const state = getState();
const { queue, notificationDisplayed } = state['features/reactions']; const { queue, notificationDisplayed } = state['features/reactions'];
const { soundsReactions } = state['features/base/settings']; const { soundsReactions } = state['features/base/settings'];
const disabledSounds = getDisabledSounds(state);
const reactions = action.reactions; const reactions = action.reactions;
batch(() => { batch(() => {
if (!notificationDisplayed && soundsReactions && displayReactionSoundsNotification) { if (!notificationDisplayed && soundsReactions && !disabledSounds.includes(REACTION_SOUND)
&& displayReactionSoundsNotification) {
dispatch(displayReactionSoundsNotification()); dispatch(displayReactionSoundsNotification());
} }
if (soundsReactions) { if (soundsReactions) {