From 7fa941cb8c34e2faf6786deec9be24471b94c615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 20 Jun 2018 12:22:26 +0200 Subject: [PATCH] [iOS] Fix setting call type in CallKit Your truly introduced this regression in 8c7a3f16b10d7e5b2b27f353f838e9446164fe75, 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. --- react/features/mobile/callkit/middleware.js | 41 ++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/react/features/mobile/callkit/middleware.js b/react/features/mobile/callkit/middleware.js index f55c12d15..f41daa278 100644 --- a/react/features/mobile/callkit/middleware.js +++ b/react/features/mobile/callkit/middleware.js @@ -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