[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
This commit is contained in:
Paweł Domas 2017-08-08 15:27:44 +01:00 committed by Saúl Ibarra Corretgé
parent cfe7e30550
commit 194b3ac9d3
1 changed files with 26 additions and 26 deletions

View File

@ -168,28 +168,19 @@ export function conferenceFailed(conference, error) {
} }
/** /**
* Attach any pre-existing local media to the conference once the conference has * Signals that a specific conference has been joined.
* been joined.
* *
* @param {JitsiConference} conference - The JitsiConference instance which was * @param {JitsiConference} conference - The JitsiConference instance which was
* joined by the local participant. * joined by the local participant.
* @returns {Function} * @returns {{
* type: CONFERENCE_JOINED,
* conference: JitsiConference
* }}
*/ */
export function conferenceJoined(conference) { export function conferenceJoined(conference) {
return (dispatch, getState) => { return {
const localTracks type: CONFERENCE_JOINED,
= getState()['features/base/tracks'] conference
.filter(t => t.local)
.map(t => t.jitsiTrack);
if (localTracks.length) {
_addLocalTracksToConference(conference, localTracks);
}
dispatch({
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 * Attaches any pre-existing local media to the conference, before
* specific conference. Similar in fashion to {@code CONFERENCE_JOINED}. * 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 * @param {JitsiConference} conference - The JitsiConference instance the
* local participant will (try to) join. * local participant will (try to) join.
* @returns {{ * @returns {Function}
* type: CONFERENCE_WILL_JOIN,
* conference: JitsiConference
* }}
*/ */
function _conferenceWillJoin(conference) { function _conferenceWillJoin(conference) {
return { return (dispatch, getState) => {
type: CONFERENCE_WILL_JOIN, const localTracks
conference = getState()['features/base/tracks']
.filter(t => t.local)
.map(t => t.jitsiTrack);
if (localTracks.length) {
_addLocalTracksToConference(conference, localTracks);
}
dispatch({
type: CONFERENCE_WILL_JOIN,
conference
});
}; };
} }