[iOS] Fix setting call type in CallKit

Your truly introduced this regression in
8c7a3f16b1, alas.

The audio only mode is used to set the CallKit call type. This affects the
behavior on the recent calls entries (calls are marked either as audio or video
calls).

Sync both at the start and for transitions. The previous code was working by
chance (in a way): when the CallKit UI is presented the local video is muted,
which triggers a SET_VIDEO_MUTED action, at which point the audio-only mode was
checked for. Now we are more explicit and act on SET_AUDIO_MUTED.
This commit is contained in:
Saúl Ibarra Corretgé 2018-06-20 12:22:26 +02:00 committed by Любомир Маринов
parent ad259988b9
commit 7fa941cb8c
1 changed files with 40 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import {
CONFERENCE_LEFT,
CONFERENCE_WILL_JOIN,
CONFERENCE_JOINED,
SET_AUDIO_ONLY,
getCurrentConference
} from '../../base/conference';
import { getInviteURL } from '../../base/connection';
@ -66,6 +67,9 @@ CallKit && MiddlewareRegistry.register(store => next => action => {
case CONFERENCE_WILL_JOIN:
return _conferenceWillJoin(store, next, action);
case SET_AUDIO_ONLY:
return _setAudioOnly(store, next, action);
case TRACK_ADDED:
case TRACK_REMOVED:
case TRACK_UPDATED:
@ -247,7 +251,8 @@ function _conferenceWillJoin({ getState }, next, action) {
state['features/base/tracks'],
MEDIA_TYPE.AUDIO);
CallKit.updateCall(conference.callUUID, { displayName });
// eslint-disable-next-line object-property-newline
CallKit.updateCall(conference.callUUID, { displayName, hasVideo });
CallKit.setMuted(conference.callUUID, muted);
});
@ -301,6 +306,40 @@ function _onPerformSetMutedCallAction({ callUUID, muted: newValue }) {
}
}
/**
* Update CallKit with the audio only state of the conference. When a conference
* is in audio only mode we will tell CallKit the call has no video. This
* affects how the call is saved in the recent calls list.
*
* XXX: Note that here we are taking the `audioOnly` value straight from the
* action, instead of examining the state. This is intentional, as setting the
* audio only involves multiple actions which will be reflected in the state
* later, but we are just interested in knowing if the mode is going to be
* set or not.
*
* @param {Store} store - The redux store in which the specified {@code action}
* is being dispatched.
* @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
* specified {@code action} in the specified {@code store}.
* @param {Action} action - The redux action which is being dispatched in the
* specified {@code store}.
* @private
* @returns {*} The value returned by {@code next(action)}.
*/
function _setAudioOnly({ getState }, next, action) {
const result = next(action);
const state = getState();
const conference = getCurrentConference(state);
if (conference && conference.callUUID) {
CallKit.updateCall(
conference.callUUID,
{ hasVideo: !action.audioOnly });
}
return result;
}
/**
* Notifies the feature callkit that the action
* {@link _SET_CALLKIT_SUBSCRIPTIONS} is being dispatched within a specific