Browse Source

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

master
robertpin 4 years ago
parent
commit
31ce7e010d
No account linked to committer's email address

+ 1
- 0
config.js View File

@@ -772,6 +772,7 @@ var config = {
772 772
     // - 'PARTICIPANT_JOINED_SOUND'
773 773
     // - 'PARTICIPANT_LEFT_SOUND'
774 774
     // - 'RAISE_HAND_SOUND'
775
+    // - 'REACTION_SOUND'
775 776
     // - 'RECORDING_OFF_SOUND'
776 777
     // - 'RECORDING_ON_SOUND'
777 778
     // - 'TALK_WHILE_MUTED_SOUND'

+ 1
- 1
react/features/base/sounds/actions.js View File

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

+ 11
- 6
react/features/reactions/constants.js View File

@@ -14,13 +14,18 @@ import {
14 14
  */
15 15
 export const ENDPOINT_REACTION_NAME = 'endpoint-reaction';
16 16
 
17
+/**
18
+ * The prefix for all reaction sound IDs. Also the ID used in config to disable reaction sounds.
19
+ */
20
+export const REACTION_SOUND = 'REACTION_SOUND';
21
+
17 22
 /**
18 23
  * The audio ID prefix of the audio element for which the {@link playAudio} action is
19 24
  * triggered when a new laugh reaction is received.
20 25
  *
21 26
  * @type { string }
22 27
  */
23
-export const LAUGH_SOUND_ID = 'LAUGH_SOUND_';
28
+export const LAUGH_SOUND_ID = `${REACTION_SOUND}_LAUGH_`;
24 29
 
25 30
 /**
26 31
  * 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_';
28 33
  *
29 34
  * @type {string}
30 35
  */
31
-export const CLAP_SOUND_ID = 'CLAP_SOUND_';
36
+export const CLAP_SOUND_ID = `${REACTION_SOUND}_CLAP_`;
32 37
 
33 38
 /**
34 39
  * 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_';
36 41
  *
37 42
  * @type {string}
38 43
  */
39
-export const LIKE_SOUND_ID = 'LIKE_SOUND_';
44
+export const LIKE_SOUND_ID = `${REACTION_SOUND}_LIKE_`;
40 45
 
41 46
 /**
42 47
  * 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_';
44 49
  *
45 50
  * @type {string}
46 51
  */
47
-export const BOO_SOUND_ID = 'BOO_SOUND_';
52
+export const BOO_SOUND_ID = `${REACTION_SOUND}_BOO_`;
48 53
 
49 54
 /**
50 55
  * 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_';
52 57
  *
53 58
  * @type {string}
54 59
  */
55
-export const SURPRISE_SOUND_ID = 'SURPRISE_SOUND_';
60
+export const SURPRISE_SOUND_ID = `${REACTION_SOUND}_SURPRISE_`;
56 61
 
57 62
 /**
58 63
  * 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_';
60 65
  *
61 66
  * @type {string}
62 67
  */
63
-export const SILENCE_SOUND_ID = 'SILENCE_SOUND_';
68
+export const SILENCE_SOUND_ID = `${REACTION_SOUND}_SILENCE_`;
64 69
 
65 70
 /**
66 71
  * The audio ID of the audio element for which the {@link playAudio} action is

+ 11
- 2
react/features/reactions/middleware.js View File

@@ -7,6 +7,7 @@ import { getParticipantCount } from '../base/participants';
7 7
 import { MiddlewareRegistry } from '../base/redux';
8 8
 import { updateSettings } from '../base/settings';
9 9
 import { playSound, registerSound, unregisterSound } from '../base/sounds';
10
+import { getDisabledSounds } from '../base/sounds/functions.any';
10 11
 import { isVpaasMeeting } from '../jaas/functions';
11 12
 import { NOTIFICATION_TIMEOUT, showNotification } from '../notifications';
12 13
 
@@ -25,7 +26,13 @@ import {
25 26
     sendReactions,
26 27
     setReactionQueue
27 28
 } from './actions.any';
28
-import { ENDPOINT_REACTION_NAME, RAISE_HAND_SOUND_ID, REACTIONS, SOUNDS_THRESHOLDS } from './constants';
29
+import {
30
+    ENDPOINT_REACTION_NAME,
31
+    RAISE_HAND_SOUND_ID,
32
+    REACTIONS,
33
+    REACTION_SOUND,
34
+    SOUNDS_THRESHOLDS
35
+} from './constants';
29 36
 import {
30 37
     getReactionMessageFromBuffer,
31 38
     getReactionsSoundsThresholds,
@@ -128,10 +135,12 @@ MiddlewareRegistry.register(store => next => action => {
128 135
         const state = getState();
129 136
         const { queue, notificationDisplayed } = state['features/reactions'];
130 137
         const { soundsReactions } = state['features/base/settings'];
138
+        const disabledSounds = getDisabledSounds(state);
131 139
         const reactions = action.reactions;
132 140
 
133 141
         batch(() => {
134
-            if (!notificationDisplayed && soundsReactions && displayReactionSoundsNotification) {
142
+            if (!notificationDisplayed && soundsReactions && !disabledSounds.includes(REACTION_SOUND)
143
+                && displayReactionSoundsNotification) {
135 144
                 dispatch(displayReactionSoundsNotification());
136 145
             }
137 146
             if (soundsReactions) {

Loading…
Cancel
Save