Flow, coding style
This commit is contained in:
parent
bb39ffe562
commit
2d73e9ace4
@ -185,7 +185,7 @@ function _pinParticipant(store, next, action) {
|
|||||||
let videoType;
|
let videoType;
|
||||||
|
|
||||||
if ((participantById && participantById.local)
|
if ((participantById && participantById.local)
|
||||||
|| (!id && pinnedParticipant && pinnedParticipant.local)) {
|
|| (!id && pinnedParticipant && pinnedParticipant.local)) {
|
||||||
videoType = 'local';
|
videoType = 'local';
|
||||||
} else {
|
} else {
|
||||||
videoType = 'remote';
|
videoType = 'remote';
|
||||||
|
|||||||
@ -32,6 +32,22 @@ export function dominantSpeakerChanged(id) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an action for removing a participant from the conference.
|
||||||
|
*
|
||||||
|
* @param {string} id - Participant's ID.
|
||||||
|
* @returns {{
|
||||||
|
* type: KICK_PARTICIPANT,
|
||||||
|
* id: string
|
||||||
|
* }}
|
||||||
|
*/
|
||||||
|
export function kickParticipant(id) {
|
||||||
|
return {
|
||||||
|
type: KICK_PARTICIPANT,
|
||||||
|
id
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an action to signal the connection status of the local participant
|
* Creates an action to signal the connection status of the local participant
|
||||||
* has changed.
|
* has changed.
|
||||||
@ -47,27 +63,12 @@ export function localParticipantConnectionStatusChanged(connectionStatus) {
|
|||||||
|
|
||||||
if (participant) {
|
if (participant) {
|
||||||
return dispatch(participantConnectionStatusChanged(
|
return dispatch(participantConnectionStatusChanged(
|
||||||
participant.id, connectionStatus));
|
participant.id,
|
||||||
|
connectionStatus));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an action for removing a participant from the conference.
|
|
||||||
*
|
|
||||||
* @param {string} id - Participant's ID.
|
|
||||||
* @returns {{
|
|
||||||
* type: KICK_PARTICIPANT,
|
|
||||||
* id: string
|
|
||||||
* }}
|
|
||||||
*/
|
|
||||||
export function kickParticipant(id) {
|
|
||||||
return {
|
|
||||||
type: KICK_PARTICIPANT,
|
|
||||||
id
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action to signal that the ID of local participant has changed. It happens
|
* Action to signal that the ID of local participant has changed. It happens
|
||||||
* when the local participant joins a new conference or leaves an existing
|
* when the local participant joins a new conference or leaves an existing
|
||||||
@ -106,6 +107,21 @@ export function localParticipantJoined(participant = {}) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action to remove a local participant.
|
||||||
|
*
|
||||||
|
* @returns {Function}
|
||||||
|
*/
|
||||||
|
export function localParticipantLeft() {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
const participant = getLocalParticipant(getState);
|
||||||
|
|
||||||
|
if (participant) {
|
||||||
|
return dispatch(participantLeft(participant.id));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action to signal the role of the local participant has changed. It can happen
|
* Action to signal the role of the local participant has changed. It can happen
|
||||||
* when the participant has joined a conference, even before a non-default local
|
* when the participant has joined a conference, even before a non-default local
|
||||||
@ -164,21 +180,6 @@ export function participantConnectionStatusChanged(id, connectionStatus) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Action to remove a local participant.
|
|
||||||
*
|
|
||||||
* @returns {Function}
|
|
||||||
*/
|
|
||||||
export function localParticipantLeft() {
|
|
||||||
return (dispatch, getState) => {
|
|
||||||
const participant = getLocalParticipant(getState);
|
|
||||||
|
|
||||||
if (participant) {
|
|
||||||
return dispatch(participantLeft(participant.id));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action to signal that a participant's display name has changed.
|
* Action to signal that a participant's display name has changed.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -110,33 +110,35 @@ function _electLastVisibleRemoteVideo(tracks) {
|
|||||||
* @returns {(string|undefined)}
|
* @returns {(string|undefined)}
|
||||||
*/
|
*/
|
||||||
function _electParticipantInLargeVideo(state) {
|
function _electParticipantInLargeVideo(state) {
|
||||||
// First get the pinned participant. If a participant is pinned, they will
|
// 1. If a participant is pinned, they will be shown in the LargeVideo (
|
||||||
// be shown in the LargeVideo.
|
// regardless of whether they are local or remote).
|
||||||
const participants = state['features/base/participants'];
|
const participants = state['features/base/participants'];
|
||||||
let participant = participants.find(p => p.pinned);
|
let participant = participants.find(p => p.pinned);
|
||||||
let id = participant && participant.id;
|
let id = participant && participant.id;
|
||||||
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
// No participant is pinned so get the dominant speaker. But the local
|
// 2. No participant is pinned so get the dominant speaker. But the
|
||||||
// participant won't be displayed in LargeVideo even if he/she is the
|
// local participant won't be displayed in LargeVideo even if she is
|
||||||
// dominant speaker.
|
// the dominant speaker.
|
||||||
participant = participants.find(p => p.dominantSpeaker && !p.local);
|
participant = participants.find(p => p.dominantSpeaker && !p.local);
|
||||||
id = participant && participant.id;
|
id = participant && participant.id;
|
||||||
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
// There is no dominant speaker so select the participant which last
|
// 3. There is no dominant speaker so select the remote participant
|
||||||
// had visible video (excluding ourselves).
|
// who last had visible video.
|
||||||
const tracks = state['features/base/tracks'];
|
const tracks = state['features/base/tracks'];
|
||||||
const videoTrack = _electLastVisibleRemoteVideo(tracks);
|
const videoTrack = _electLastVisibleRemoteVideo(tracks);
|
||||||
|
|
||||||
id = videoTrack && videoTrack.participantId;
|
id = videoTrack && videoTrack.participantId;
|
||||||
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
// It's possible there is no participant with visible video,
|
// 4. It's possible there is no participant with visible video.
|
||||||
// this can happen for a number or reasons:
|
// This can happen for a number of reasons:
|
||||||
// - there is only one participant (the local user)
|
// - there is only one participant (i.e. the local user),
|
||||||
// - other participants joined with video muted
|
// - other participants joined with video muted.
|
||||||
// As a last resort, pick the last participant.
|
// As a last resort, pick the last participant who joined the
|
||||||
|
// conference (regardless of whether they are local or
|
||||||
|
// remote).
|
||||||
participant = participants[participants.length - 1];
|
participant = participants[participants.length - 1];
|
||||||
id = participant && participant.id;
|
id = participant && participant.id;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
// @flow
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DOMINANT_SPEAKER_CHANGED,
|
DOMINANT_SPEAKER_CHANGED,
|
||||||
PARTICIPANT_JOINED,
|
PARTICIPANT_JOINED,
|
||||||
@ -12,10 +14,7 @@ import {
|
|||||||
TRACK_UPDATED
|
TRACK_UPDATED
|
||||||
} from '../base/tracks';
|
} from '../base/tracks';
|
||||||
|
|
||||||
import {
|
import { selectParticipant, selectParticipantInLargeVideo } from './actions';
|
||||||
selectParticipant,
|
|
||||||
selectParticipantInLargeVideo
|
|
||||||
} from './actions';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Middleware that catches actions related to participants and tracks and
|
* Middleware that catches actions related to participants and tracks and
|
||||||
@ -37,7 +36,7 @@ MiddlewareRegistry.register(store => next => action => {
|
|||||||
store.dispatch(selectParticipantInLargeVideo());
|
store.dispatch(selectParticipantInLargeVideo());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TRACK_UPDATED: {
|
case TRACK_UPDATED:
|
||||||
// In order to minimize re-calculations, we need to select participant
|
// In order to minimize re-calculations, we need to select participant
|
||||||
// only if the videoType of the current participant rendered in
|
// only if the videoType of the current participant rendered in
|
||||||
// LargeVideo has changed.
|
// LargeVideo has changed.
|
||||||
@ -54,7 +53,6 @@ MiddlewareRegistry.register(store => next => action => {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
// @flow
|
||||||
|
|
||||||
import { PARTICIPANT_ID_CHANGED } from '../base/participants';
|
import { PARTICIPANT_ID_CHANGED } from '../base/participants';
|
||||||
import { ReducerRegistry } from '../base/redux';
|
import { ReducerRegistry } from '../base/redux';
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user