jiti-meet/react/features/base/participants/actions.js

235 lines
4.9 KiB
JavaScript
Raw Normal View History

import {
DOMINANT_SPEAKER_CHANGED,
PARTICIPANT_ID_CHANGED,
PARTICIPANT_JOINED,
PARTICIPANT_LEFT,
PARTICIPANT_UPDATED,
PIN_PARTICIPANT
} from './actionTypes';
import { getLocalParticipant } from './functions';
2017-02-27 21:42:28 +00:00
/**
2017-03-07 16:50:17 +00:00
* Action to update a participant's avatar ID.
2017-02-27 21:42:28 +00:00
*
2017-03-07 16:50:17 +00:00
* @param {string} id - Participant's ID.
* @param {string} avatarID - Participant's avatar ID.
2017-02-27 21:42:28 +00:00
* @returns {{
2017-03-07 16:50:17 +00:00
* type: PARTICIPANT_UPDATED,
* participant: {
* id: string,
* avatarID: string,
* }
2017-02-27 21:42:28 +00:00
* }}
*/
2017-03-07 16:50:17 +00:00
export function changeParticipantAvatarID(id, avatarID) {
2017-02-27 21:42:28 +00:00
return {
type: PARTICIPANT_UPDATED,
participant: {
id,
2017-03-07 16:50:17 +00:00
avatarID
2017-02-27 21:42:28 +00:00
}
};
}
/**
* Action to update a participant's avatar URL.
*
2017-03-07 16:50:17 +00:00
* @param {string} id - Participant's ID.
* @param {string} avatarURL - Participant's avatar URL.
2017-02-27 21:42:28 +00:00
* @returns {{
2017-03-07 16:50:17 +00:00
* type: PARTICIPANT_UPDATED,
* participant: {
* id: string,
* avatarURL: string,
* }
2017-02-27 21:42:28 +00:00
* }}
*/
2017-03-07 16:50:17 +00:00
export function changeParticipantAvatarURL(id, avatarURL) {
2017-02-27 21:42:28 +00:00
return {
type: PARTICIPANT_UPDATED,
participant: {
id,
2017-03-07 16:50:17 +00:00
avatarURL
2017-02-27 21:42:28 +00:00
}
};
}
/**
* Action to update a participant's email.
*
2017-03-07 16:50:17 +00:00
* @param {string} id - Participant's ID.
* @param {string} email - Participant's email.
* @returns {{
2017-03-07 16:50:17 +00:00
* type: PARTICIPANT_UPDATED,
* participant: {
* id: string,
* email: string
* }
* }}
*/
export function changeParticipantEmail(id, email) {
return {
type: PARTICIPANT_UPDATED,
participant: {
id,
email
}
};
}
/**
* Create an action for when dominant speaker changes.
*
2017-03-07 16:50:17 +00:00
* @param {string} id - Participant's ID.
* @returns {{
2017-03-07 16:50:17 +00:00
* type: DOMINANT_SPEAKER_CHANGED,
* participant: {
* id: string
* }
* }}
*/
export function dominantSpeakerChanged(id) {
return {
type: DOMINANT_SPEAKER_CHANGED,
participant: {
id
}
};
}
/**
* Action to signal that ID of local participant has changed. This happens when
* local participant joins a new conference or quits one.
*
* @param {string} id - New ID for local participant.
* @returns {{
2017-03-07 16:50:17 +00:00
* type: PARTICIPANT_ID_CHANGED,
* newValue: string,
* oldValue: string
* }}
*/
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
* }}
*/
export function localParticipantJoined(participant = {}) {
return participantJoined({
...participant,
local: true
});
}
/**
* 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.
*
2017-03-07 16:50:17 +00:00
* @param {string} id - Participant's ID.
* @returns {{
2017-03-07 16:50:17 +00:00
* type: PARTICIPANT_LEFT,
* participant: {
* id: string
* }
* }}
*/
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.
*
2017-03-07 16:50:17 +00:00
* @param {string} id - Participant's ID.
* @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
* }
* }}
*/
export function participantRoleChanged(id, role) {
return {
type: PARTICIPANT_UPDATED,
participant: {
id,
role
}
};
}
/**
* 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
* }
* }}
*/
export function pinParticipant(id) {
return {
type: PIN_PARTICIPANT,
participant: {
id
}
};
}