[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
* 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
});
};
}