123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- import {
- DOMINANT_SPEAKER_CHANGED,
- PARTICIPANT_ID_CHANGED,
- PARTICIPANT_JOINED,
- PARTICIPANT_LEFT,
- PARTICIPANT_UPDATED,
- PIN_PARTICIPANT
- } from './actionTypes';
- import { getLocalParticipant } from './functions';
-
- /**
- * Action to update a participant's email.
- *
- * @param {string} id - Participant's id.
- * @param {string} email - Participant's email.
- * @returns {{
- * type: PARTICIPANT_UPDATED,
- * participant: {
- * id: string,
- * avatar: string,
- * email: string
- * }
- * }}
- */
- export function changeParticipantEmail(id, email) {
- return {
- type: PARTICIPANT_UPDATED,
- participant: {
- id,
- email
- }
- };
- }
-
- /**
- * Create an action for when dominant speaker changes.
- *
- * @param {string} id - Participant id.
- * @returns {{
- * 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 {{
- * 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 {{
- * 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
- };
- }
-
- /**
- * Action to handle case when participant lefts.
- *
- * @param {string} id - Participant id.
- * @returns {{
- * type: PARTICIPANT_LEFT,
- * participant: {
- * id: string
- * }
- * }}
- */
- export function participantLeft(id) {
- return {
- type: PARTICIPANT_LEFT,
- participant: {
- id
- }
- };
- }
-
- /**
- * Action to handle case when participant's role changes.
- *
- * @param {string} id - Participant id.
- * @param {PARTICIPANT_ROLE} role - Participant's new role.
- * @returns {{
- * 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 {{
- * type: PIN_PARTICIPANT,
- * participant: {
- * id: string
- * }
- * }}
- */
- export function pinParticipant(id) {
- return {
- type: PIN_PARTICIPANT,
- participant: {
- id
- }
- };
- }
|