2016-10-05 14:36:59 +00:00
|
|
|
import {
|
|
|
|
DOMINANT_SPEAKER_CHANGED,
|
|
|
|
PARTICIPANT_ID_CHANGED,
|
|
|
|
PARTICIPANT_JOINED,
|
|
|
|
PARTICIPANT_LEFT,
|
|
|
|
PARTICIPANT_UPDATED,
|
|
|
|
PIN_PARTICIPANT
|
|
|
|
} from './actionTypes';
|
|
|
|
import { getLocalParticipant } from './functions';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create an action for when dominant speaker changes.
|
|
|
|
*
|
2017-03-07 16:50:17 +00:00
|
|
|
* @param {string} id - Participant's ID.
|
2016-10-05 14:36:59 +00:00
|
|
|
* @returns {{
|
2017-03-07 16:50:17 +00:00
|
|
|
* type: DOMINANT_SPEAKER_CHANGED,
|
|
|
|
* participant: {
|
|
|
|
* id: string
|
|
|
|
* }
|
2016-10-05 14:36:59 +00:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function dominantSpeakerChanged(id) {
|
|
|
|
return {
|
|
|
|
type: DOMINANT_SPEAKER_CHANGED,
|
|
|
|
participant: {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-04-10 21:53:30 +00:00
|
|
|
* 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
|
|
|
|
* conference.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
|
|
|
* @param {string} id - New ID for local participant.
|
2017-04-10 21:53:30 +00:00
|
|
|
* @returns {Function}
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
|
|
|
export function localParticipantIdChanged(id) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const participant = getLocalParticipant(getState);
|
|
|
|
|
|
|
|
if (participant) {
|
|
|
|
return dispatch({
|
|
|
|
type: PARTICIPANT_ID_CHANGED,
|
|
|
|
newValue: id,
|
|
|
|
oldValue: participant.id
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action to signal that a local participant has joined.
|
|
|
|
*
|
|
|
|
* @param {Participant} participant={} - Information about participant.
|
|
|
|
* @returns {{
|
2017-03-07 16:50:17 +00:00
|
|
|
* type: PARTICIPANT_JOINED,
|
|
|
|
* participant: Participant
|
2016-10-05 14:36:59 +00:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function localParticipantJoined(participant = {}) {
|
|
|
|
return participantJoined({
|
|
|
|
...participant,
|
|
|
|
local: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-04-10 21:53:30 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
* id has been set, or after a moderator leaves.
|
|
|
|
*
|
|
|
|
* @param {string} role - The new role of the local participant.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function localParticipantRoleChanged(role) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const participant = getLocalParticipant(getState);
|
|
|
|
|
|
|
|
if (participant) {
|
|
|
|
return dispatch(participantRoleChanged(participant.id, role));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-04-05 09:01:57 +00:00
|
|
|
/**
|
|
|
|
* Action to update a participant's connection status.
|
|
|
|
*
|
|
|
|
* @param {string} id - Participant's ID.
|
|
|
|
* @param {string} connectionStatus - The new connection status of the
|
|
|
|
* participant.
|
|
|
|
* @returns {{
|
|
|
|
* type: PARTICIPANT_UPDATED,
|
|
|
|
* participant: {
|
|
|
|
* connectionStatus: string,
|
|
|
|
* id: string
|
|
|
|
* }
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function participantConnectionStatusChanged(id, connectionStatus) {
|
|
|
|
return {
|
|
|
|
type: PARTICIPANT_UPDATED,
|
|
|
|
participant: {
|
|
|
|
connectionStatus,
|
|
|
|
id
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
|
|
|
* 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 has joined.
|
|
|
|
*
|
|
|
|
* @param {Participant} participant - Information about participant.
|
|
|
|
* @returns {{
|
|
|
|
* type: PARTICIPANT_JOINED,
|
|
|
|
* participant: Participant
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function participantJoined(participant) {
|
|
|
|
return {
|
|
|
|
type: PARTICIPANT_JOINED,
|
|
|
|
participant
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-03-07 16:50:17 +00:00
|
|
|
* Action to signal that a participant has left.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
2017-03-07 16:50:17 +00:00
|
|
|
* @param {string} id - Participant's ID.
|
2016-10-05 14:36:59 +00:00
|
|
|
* @returns {{
|
2017-03-07 16:50:17 +00:00
|
|
|
* type: PARTICIPANT_LEFT,
|
|
|
|
* participant: {
|
|
|
|
* id: string
|
|
|
|
* }
|
2016-10-05 14:36:59 +00:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function participantLeft(id) {
|
|
|
|
return {
|
|
|
|
type: PARTICIPANT_LEFT,
|
|
|
|
participant: {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-03-07 16:50:17 +00:00
|
|
|
* Action to signal that a participant's role has changed.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
2017-03-07 16:50:17 +00:00
|
|
|
* @param {string} id - Participant's ID.
|
2016-10-05 14:36:59 +00:00
|
|
|
* @param {PARTICIPANT_ROLE} role - Participant's new role.
|
|
|
|
* @returns {{
|
2017-03-07 16:50:17 +00:00
|
|
|
* type: PARTICIPANT_UPDATED,
|
|
|
|
* participant: {
|
|
|
|
* id: string,
|
|
|
|
* role: PARTICIPANT_ROLE
|
|
|
|
* }
|
2016-10-05 14:36:59 +00:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function participantRoleChanged(id, role) {
|
2017-03-23 18:01:33 +00:00
|
|
|
return participantUpdated({
|
|
|
|
id,
|
|
|
|
role
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action to signal that some of participant properties has been changed.
|
|
|
|
*
|
|
|
|
* @param {Participant} participant={} - Information about participant. To
|
|
|
|
* identify the participant the object should contain either property id with
|
|
|
|
* value the id of the participant or property local with value true (if the
|
|
|
|
* local participant hasn't joined the conference yet).
|
|
|
|
* @returns {{
|
|
|
|
* type: PARTICIPANT_UPDATED,
|
|
|
|
* participant: Participant
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function participantUpdated(participant = {}) {
|
2016-10-05 14:36:59 +00:00
|
|
|
return {
|
|
|
|
type: PARTICIPANT_UPDATED,
|
2017-03-23 18:01:33 +00:00
|
|
|
participant
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create an action which pins a conference participant.
|
|
|
|
*
|
|
|
|
* @param {string|null} id - The ID of the conference participant to pin or null
|
|
|
|
* if none of the conference's participants are to be pinned.
|
|
|
|
* @returns {{
|
2017-03-07 16:50:17 +00:00
|
|
|
* type: PIN_PARTICIPANT,
|
|
|
|
* participant: {
|
|
|
|
* id: string
|
|
|
|
* }
|
2016-10-05 14:36:59 +00:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function pinParticipant(id) {
|
|
|
|
return {
|
|
|
|
type: PIN_PARTICIPANT,
|
|
|
|
participant: {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|