Browse Source

[RN] Fix setting audio mode for audio-only calls

When a call is tarted in audio only mode due to the switch on the welcome page,
the wrong audio mode was chosen.
j8
Saúl Ibarra Corretgé 6 years ago
parent
commit
7ad0639f7a
1 changed files with 11 additions and 9 deletions
  1. 11
    9
      react/features/mobile/audio-mode/middleware.js

+ 11
- 9
react/features/mobile/audio-mode/middleware.js View File

@@ -11,6 +11,8 @@ import {
11 11
 } from '../../base/conference';
12 12
 import { MiddlewareRegistry } from '../../base/redux';
13 13
 
14
+const AudioMode = NativeModules.AudioMode;
15
+
14 16
 /**
15 17
  * Middleware that captures conference actions and sets the correct audio mode
16 18
  * based on the type of conference. Audio-only conferences don't use the speaker
@@ -20,7 +22,7 @@ import { MiddlewareRegistry } from '../../base/redux';
20 22
  * @returns {Function}
21 23
  */
22 24
 MiddlewareRegistry.register(({ getState }) => next => action => {
23
-    const AudioMode = NativeModules.AudioMode;
25
+    const result = next(action);
24 26
 
25 27
     if (AudioMode) {
26 28
         let mode;
@@ -43,13 +45,13 @@ MiddlewareRegistry.register(({ getState }) => next => action => {
43 45
          */
44 46
         case CONFERENCE_JOINED:
45 47
         case SET_AUDIO_ONLY: {
46
-            if (getState()['features/base/conference'].conference
47
-                    || action.conference) {
48
-                mode
49
-                    = action.audioOnly
50
-                        ? AudioMode.AUDIO_CALL
51
-                        : AudioMode.VIDEO_CALL;
52
-            }
48
+            const { audioOnly, conference }
49
+                = getState()['features/base/conference'];
50
+
51
+            conference
52
+                && (mode = audioOnly
53
+                    ? AudioMode.AUDIO_CALL
54
+                    : AudioMode.VIDEO_CALL);
53 55
             break;
54 56
         }
55 57
         }
@@ -62,5 +64,5 @@ MiddlewareRegistry.register(({ getState }) => next => action => {
62 64
         }
63 65
     }
64 66
 
65
-    return next(action);
67
+    return result;
66 68
 });

Loading…
Cancel
Save