[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.
This commit is contained in:
Saúl Ibarra Corretgé 2018-08-01 14:31:18 +02:00 committed by Saúl Ibarra Corretgé
parent 54a1853e60
commit 7ad0639f7a
1 changed files with 11 additions and 9 deletions

View File

@ -11,6 +11,8 @@ import {
} from '../../base/conference'; } from '../../base/conference';
import { MiddlewareRegistry } from '../../base/redux'; import { MiddlewareRegistry } from '../../base/redux';
const AudioMode = NativeModules.AudioMode;
/** /**
* Middleware that captures conference actions and sets the correct audio mode * Middleware that captures conference actions and sets the correct audio mode
* based on the type of conference. Audio-only conferences don't use the speaker * based on the type of conference. Audio-only conferences don't use the speaker
@ -20,7 +22,7 @@ import { MiddlewareRegistry } from '../../base/redux';
* @returns {Function} * @returns {Function}
*/ */
MiddlewareRegistry.register(({ getState }) => next => action => { MiddlewareRegistry.register(({ getState }) => next => action => {
const AudioMode = NativeModules.AudioMode; const result = next(action);
if (AudioMode) { if (AudioMode) {
let mode; let mode;
@ -43,13 +45,13 @@ MiddlewareRegistry.register(({ getState }) => next => action => {
*/ */
case CONFERENCE_JOINED: case CONFERENCE_JOINED:
case SET_AUDIO_ONLY: { case SET_AUDIO_ONLY: {
if (getState()['features/base/conference'].conference const { audioOnly, conference }
|| action.conference) { = getState()['features/base/conference'];
mode
= action.audioOnly conference
? AudioMode.AUDIO_CALL && (mode = audioOnly
: AudioMode.VIDEO_CALL; ? AudioMode.AUDIO_CALL
} : AudioMode.VIDEO_CALL);
break; break;
} }
} }
@ -62,5 +64,5 @@ MiddlewareRegistry.register(({ getState }) => next => action => {
} }
} }
return next(action); return result;
}); });