From 194b3ac9d39365fa2998b7b8a6c4eafeac7e0fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Domas?= Date: Tue, 8 Aug 2017 15:27:44 +0100 Subject: [PATCH] [RN] Add local tracks before joining the conference * ref(base/conference): add tracks before join Sometimes it will be suboptimal to add local tracks to the conference, after the room has been joined. It may slow down the session initiation process by having to send unnecessary 'source-add' notifications. * squash: fix typos/comments --- react/features/base/conference/actions.js | 52 +++++++++++------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/react/features/base/conference/actions.js b/react/features/base/conference/actions.js index 3d03bec72..4e87b1fd1 100644 --- a/react/features/base/conference/actions.js +++ b/react/features/base/conference/actions.js @@ -168,28 +168,19 @@ export function conferenceFailed(conference, error) { } /** - * Attach any pre-existing local media to the conference once the conference has - * been joined. + * Signals that a specific conference has been joined. * * @param {JitsiConference} conference - The JitsiConference instance which was * joined by the local participant. - * @returns {Function} + * @returns {{ + * type: CONFERENCE_JOINED, + * conference: JitsiConference + * }} */ export function conferenceJoined(conference) { - return (dispatch, getState) => { - const localTracks - = getState()['features/base/tracks'] - .filter(t => t.local) - .map(t => t.jitsiTrack); - - if (localTracks.length) { - _addLocalTracksToConference(conference, localTracks); - } - - dispatch({ - type: CONFERENCE_JOINED, - conference - }); + return { + type: CONFERENCE_JOINED, + conference }; } @@ -211,20 +202,29 @@ export function conferenceLeft(conference) { } /** - * Signals the intention of the application to have the local participant join a - * specific conference. Similar in fashion to {@code CONFERENCE_JOINED}. + * Attaches any pre-existing local media to the conference, before + * the conference will be joined. Then signals the intention of the application + * to have the local participant join a specific conference. * * @param {JitsiConference} conference - The JitsiConference instance the * local participant will (try to) join. - * @returns {{ - * type: CONFERENCE_WILL_JOIN, - * conference: JitsiConference - * }} + * @returns {Function} */ function _conferenceWillJoin(conference) { - return { - type: CONFERENCE_WILL_JOIN, - conference + return (dispatch, getState) => { + const localTracks + = getState()['features/base/tracks'] + .filter(t => t.local) + .map(t => t.jitsiTrack); + + if (localTracks.length) { + _addLocalTracksToConference(conference, localTracks); + } + + dispatch({ + type: CONFERENCE_WILL_JOIN, + conference + }); }; }