2017-11-21 17:38:40 +00:00
|
|
|
/* global interfaceConfig */
|
|
|
|
|
|
|
|
import throttle from 'lodash/throttle';
|
|
|
|
|
2018-05-29 01:43:28 +00:00
|
|
|
import { set } from '../redux';
|
2017-12-11 18:33:09 +00:00
|
|
|
import { showNotification } from '../../notifications';
|
2017-11-21 17:38:40 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
import {
|
|
|
|
DOMINANT_SPEAKER_CHANGED,
|
2018-07-26 16:33:40 +00:00
|
|
|
HIDDEN_PARTICIPANT_JOINED,
|
|
|
|
HIDDEN_PARTICIPANT_LEFT,
|
2017-08-14 15:02:58 +00:00
|
|
|
KICK_PARTICIPANT,
|
|
|
|
MUTE_REMOTE_PARTICIPANT,
|
2016-10-05 14:36:59 +00:00
|
|
|
PARTICIPANT_ID_CHANGED,
|
|
|
|
PARTICIPANT_JOINED,
|
|
|
|
PARTICIPANT_LEFT,
|
|
|
|
PARTICIPANT_UPDATED,
|
|
|
|
PIN_PARTICIPANT
|
|
|
|
} from './actionTypes';
|
2019-01-15 11:28:07 +00:00
|
|
|
import { getLocalParticipant, getNormalizedDisplayName } from './functions';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create an action for when dominant speaker changes.
|
|
|
|
*
|
2017-03-07 16:50:17 +00:00
|
|
|
* @param {string} id - Participant's ID.
|
Associate remote participant w/ JitsiConference (_UPDATED)
The commit message of "Associate remote participant w/ JitsiConference
(_JOINED)" explains the motivation for this commit.
Practically, _JOINED and _LEFT combined with "Remove remote participants
who are no longer of interest" should alleviate the problem with
multiplying remote participants to an acceptable level of annoyance.
Technically though, a remote participant cannot be identified by an ID
only. The ID is (somewhat) "unique" in the context of a single
JitsiConference instance. So in order to not have to scratch our heads
over an obscure corner, racing case, it's better to always identify
remote participants by the pair id-conference. Unfortunately, that's a
bit of a high order given the existing source code. So I've implemented
the cases which are the easiest so that new source code written with
participantUpdated is more likely to identify a remote participant with
the pair id-conference.
Additionally, the commit "Reduce direct read access to the
features/base/participants redux state" brings more control back to the
functions of the feature base/participants so that one day we can (if we
choose to) do something like, for example:
If getParticipants is called with a conference, it returns the
participants from features/base/participants who are associated with the
specified conference. If no conference is specified in the function
call, then default to the conference which is the primary focus of the
app at the time of the function call. Added to the above, this should
allow us to further reduce the cases in which we're identifying remote
participants by id only and get us even closer to a more "predictable"
behavior in corner, racing cases.
2018-05-22 21:47:43 +00:00
|
|
|
* @param {JitsiConference} conference - The {@code JitsiConference} associated
|
|
|
|
* with the participant identified by the specified {@code id}. Only the local
|
|
|
|
* participant is allowed to not specify an associated {@code JitsiConference}
|
|
|
|
* instance.
|
2016-10-05 14:36:59 +00:00
|
|
|
* @returns {{
|
2017-03-07 16:50:17 +00:00
|
|
|
* type: DOMINANT_SPEAKER_CHANGED,
|
|
|
|
* participant: {
|
Associate remote participant w/ JitsiConference (_UPDATED)
The commit message of "Associate remote participant w/ JitsiConference
(_JOINED)" explains the motivation for this commit.
Practically, _JOINED and _LEFT combined with "Remove remote participants
who are no longer of interest" should alleviate the problem with
multiplying remote participants to an acceptable level of annoyance.
Technically though, a remote participant cannot be identified by an ID
only. The ID is (somewhat) "unique" in the context of a single
JitsiConference instance. So in order to not have to scratch our heads
over an obscure corner, racing case, it's better to always identify
remote participants by the pair id-conference. Unfortunately, that's a
bit of a high order given the existing source code. So I've implemented
the cases which are the easiest so that new source code written with
participantUpdated is more likely to identify a remote participant with
the pair id-conference.
Additionally, the commit "Reduce direct read access to the
features/base/participants redux state" brings more control back to the
functions of the feature base/participants so that one day we can (if we
choose to) do something like, for example:
If getParticipants is called with a conference, it returns the
participants from features/base/participants who are associated with the
specified conference. If no conference is specified in the function
call, then default to the conference which is the primary focus of the
app at the time of the function call. Added to the above, this should
allow us to further reduce the cases in which we're identifying remote
participants by id only and get us even closer to a more "predictable"
behavior in corner, racing cases.
2018-05-22 21:47:43 +00:00
|
|
|
* conference: JitsiConference,
|
2017-03-07 16:50:17 +00:00
|
|
|
* id: string
|
|
|
|
* }
|
2016-10-05 14:36:59 +00:00
|
|
|
* }}
|
|
|
|
*/
|
Associate remote participant w/ JitsiConference (_UPDATED)
The commit message of "Associate remote participant w/ JitsiConference
(_JOINED)" explains the motivation for this commit.
Practically, _JOINED and _LEFT combined with "Remove remote participants
who are no longer of interest" should alleviate the problem with
multiplying remote participants to an acceptable level of annoyance.
Technically though, a remote participant cannot be identified by an ID
only. The ID is (somewhat) "unique" in the context of a single
JitsiConference instance. So in order to not have to scratch our heads
over an obscure corner, racing case, it's better to always identify
remote participants by the pair id-conference. Unfortunately, that's a
bit of a high order given the existing source code. So I've implemented
the cases which are the easiest so that new source code written with
participantUpdated is more likely to identify a remote participant with
the pair id-conference.
Additionally, the commit "Reduce direct read access to the
features/base/participants redux state" brings more control back to the
functions of the feature base/participants so that one day we can (if we
choose to) do something like, for example:
If getParticipants is called with a conference, it returns the
participants from features/base/participants who are associated with the
specified conference. If no conference is specified in the function
call, then default to the conference which is the primary focus of the
app at the time of the function call. Added to the above, this should
allow us to further reduce the cases in which we're identifying remote
participants by id only and get us even closer to a more "predictable"
behavior in corner, racing cases.
2018-05-22 21:47:43 +00:00
|
|
|
export function dominantSpeakerChanged(id, conference) {
|
2016-10-05 14:36:59 +00:00
|
|
|
return {
|
|
|
|
type: DOMINANT_SPEAKER_CHANGED,
|
|
|
|
participant: {
|
Associate remote participant w/ JitsiConference (_UPDATED)
The commit message of "Associate remote participant w/ JitsiConference
(_JOINED)" explains the motivation for this commit.
Practically, _JOINED and _LEFT combined with "Remove remote participants
who are no longer of interest" should alleviate the problem with
multiplying remote participants to an acceptable level of annoyance.
Technically though, a remote participant cannot be identified by an ID
only. The ID is (somewhat) "unique" in the context of a single
JitsiConference instance. So in order to not have to scratch our heads
over an obscure corner, racing case, it's better to always identify
remote participants by the pair id-conference. Unfortunately, that's a
bit of a high order given the existing source code. So I've implemented
the cases which are the easiest so that new source code written with
participantUpdated is more likely to identify a remote participant with
the pair id-conference.
Additionally, the commit "Reduce direct read access to the
features/base/participants redux state" brings more control back to the
functions of the feature base/participants so that one day we can (if we
choose to) do something like, for example:
If getParticipants is called with a conference, it returns the
participants from features/base/participants who are associated with the
specified conference. If no conference is specified in the function
call, then default to the conference which is the primary focus of the
app at the time of the function call. Added to the above, this should
allow us to further reduce the cases in which we're identifying remote
participants by id only and get us even closer to a more "predictable"
behavior in corner, racing cases.
2018-05-22 21:47:43 +00:00
|
|
|
conference,
|
2016-10-05 14:36:59 +00:00
|
|
|
id
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-10-09 15:03:02 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-07-13 00:26:10 +00:00
|
|
|
/**
|
|
|
|
* Creates an action to signal the connection status of the local participant
|
|
|
|
* has changed.
|
|
|
|
*
|
|
|
|
* @param {string} connectionStatus - The current connection status of the local
|
|
|
|
* participant, as enumerated by the library's participantConnectionStatus
|
|
|
|
* constants.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function localParticipantConnectionStatusChanged(connectionStatus) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const participant = getLocalParticipant(getState);
|
|
|
|
|
|
|
|
if (participant) {
|
|
|
|
return dispatch(participantConnectionStatusChanged(
|
2017-10-09 15:03:02 +00:00
|
|
|
participant.id,
|
|
|
|
connectionStatus));
|
2017-07-13 00:26:10 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
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,
|
2018-05-27 20:42:13 +00:00
|
|
|
|
|
|
|
// XXX A participant is identified by an id-conference pair.
|
|
|
|
// Only the local participant is with an undefined conference.
|
|
|
|
conference: undefined,
|
2016-10-05 14:36:59 +00:00
|
|
|
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 = {}) {
|
2018-05-29 01:43:28 +00:00
|
|
|
return participantJoined(set(participant, 'local', true));
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
|
2017-10-09 15:03:02 +00:00
|
|
|
/**
|
|
|
|
* Action to remove a local participant.
|
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function localParticipantLeft() {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const participant = getLocalParticipant(getState);
|
|
|
|
|
|
|
|
if (participant) {
|
2018-05-22 21:08:35 +00:00
|
|
|
return (
|
|
|
|
dispatch(
|
|
|
|
participantLeft(
|
|
|
|
participant.id,
|
|
|
|
|
|
|
|
// XXX Only the local participant is allowed to leave
|
|
|
|
// without stating the JitsiConference instance because
|
|
|
|
// the local participant is uniquely identified by the
|
|
|
|
// very fact that there is only one local participant
|
|
|
|
// (and the fact that the local participant "joins" at
|
|
|
|
// the beginning of the app and "leaves" at the end of
|
|
|
|
// the app).
|
|
|
|
undefined)));
|
2017-10-09 15:03:02 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
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-08-14 15:02:58 +00:00
|
|
|
/**
|
|
|
|
* Create an action for muting another participant in the conference.
|
|
|
|
*
|
|
|
|
* @param {string} id - Participant's ID.
|
|
|
|
* @returns {{
|
|
|
|
* type: MUTE_REMOTE_PARTICIPANT,
|
|
|
|
* id: string
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function muteRemoteParticipant(id) {
|
|
|
|
return {
|
|
|
|
type: MUTE_REMOTE_PARTICIPANT,
|
|
|
|
id
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
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 signal that a participant has joined.
|
|
|
|
*
|
|
|
|
* @param {Participant} participant - Information about participant.
|
|
|
|
* @returns {{
|
2018-05-22 19:30:51 +00:00
|
|
|
* type: PARTICIPANT_JOINED,
|
|
|
|
* participant: Participant
|
2016-10-05 14:36:59 +00:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function participantJoined(participant) {
|
2018-05-28 00:13:26 +00:00
|
|
|
// Only the local participant is not identified with an id-conference pair.
|
|
|
|
if (participant.local) {
|
|
|
|
return {
|
|
|
|
type: PARTICIPANT_JOINED,
|
|
|
|
participant
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// In other words, a remote participant is identified with an id-conference
|
|
|
|
// pair.
|
|
|
|
const { conference } = participant;
|
|
|
|
|
|
|
|
if (!conference) {
|
2018-05-22 19:30:51 +00:00
|
|
|
throw Error(
|
|
|
|
'A remote participant must be associated with a JitsiConference!');
|
|
|
|
}
|
|
|
|
|
2018-05-28 00:13:26 +00:00
|
|
|
return (dispatch, getState) => {
|
|
|
|
// A remote participant is only expected to join in a joined or joining
|
|
|
|
// conference. The following check is really necessary because a
|
|
|
|
// JitsiConference may have moved into leaving but may still manage to
|
|
|
|
// sneak a PARTICIPANT_JOINED in if its leave is delayed for any purpose
|
|
|
|
// (which is not outragous given that leaving involves network
|
|
|
|
// requests.)
|
|
|
|
const stateFeaturesBaseConference
|
|
|
|
= getState()['features/base/conference'];
|
|
|
|
|
|
|
|
if (conference === stateFeaturesBaseConference.conference
|
|
|
|
|| conference === stateFeaturesBaseConference.joining) {
|
|
|
|
return dispatch({
|
|
|
|
type: PARTICIPANT_JOINED,
|
|
|
|
participant
|
|
|
|
});
|
|
|
|
}
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-07-26 16:33:40 +00:00
|
|
|
/**
|
|
|
|
* Action to signal that a hidden participant has joined the conference.
|
|
|
|
*
|
|
|
|
* @param {string} id - The id of the participant.
|
|
|
|
* @param {string} displayName - The display name, or undefined when
|
|
|
|
* unknown.
|
|
|
|
* @returns {{
|
|
|
|
* type: HIDDEN_PARTICIPANT_JOINED,
|
|
|
|
* displayName: string,
|
|
|
|
* id: string
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function hiddenParticipantJoined(id, displayName) {
|
|
|
|
return {
|
|
|
|
type: HIDDEN_PARTICIPANT_JOINED,
|
|
|
|
id,
|
|
|
|
displayName
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action to signal that a hidden participant has left the conference.
|
|
|
|
*
|
|
|
|
* @param {string} id - The id of the participant.
|
|
|
|
* @returns {{
|
|
|
|
* type: HIDDEN_PARTICIPANT_LEFT,
|
|
|
|
* id: string
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function hiddenParticipantLeft(id) {
|
|
|
|
return {
|
|
|
|
type: HIDDEN_PARTICIPANT_LEFT,
|
|
|
|
id
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
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.
|
2018-05-22 21:08:35 +00:00
|
|
|
* @param {JitsiConference} conference - The {@code JitsiConference} associated
|
|
|
|
* with the participant identified by the specified {@code id}. Only the local
|
|
|
|
* participant is allowed to not specify an associated {@code JitsiConference}
|
|
|
|
* instance.
|
2016-10-05 14:36:59 +00:00
|
|
|
* @returns {{
|
2017-03-07 16:50:17 +00:00
|
|
|
* type: PARTICIPANT_LEFT,
|
|
|
|
* participant: {
|
2018-05-22 21:08:35 +00:00
|
|
|
* conference: JitsiConference,
|
2017-03-07 16:50:17 +00:00
|
|
|
* id: string
|
|
|
|
* }
|
2016-10-05 14:36:59 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2018-05-22 21:08:35 +00:00
|
|
|
export function participantLeft(id, conference) {
|
2016-10-05 14:36:59 +00:00
|
|
|
return {
|
|
|
|
type: PARTICIPANT_LEFT,
|
|
|
|
participant: {
|
2018-05-22 21:08:35 +00:00
|
|
|
conference,
|
2016-10-05 14:36:59 +00:00
|
|
|
id
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-07-31 23:33:22 +00:00
|
|
|
/**
|
|
|
|
* Action to signal that a participant's presence status has changed.
|
|
|
|
*
|
|
|
|
* @param {string} id - Participant's ID.
|
|
|
|
* @param {string} presence - Participant's new presence status.
|
|
|
|
* @returns {{
|
|
|
|
* type: PARTICIPANT_UPDATED,
|
|
|
|
* participant: {
|
|
|
|
* id: string,
|
|
|
|
* presence: string
|
|
|
|
* }
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function participantPresenceChanged(id, presence) {
|
|
|
|
return participantUpdated({
|
|
|
|
id,
|
|
|
|
presence
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
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 = {}) {
|
2019-01-15 11:28:07 +00:00
|
|
|
const participantToUpdate = {
|
|
|
|
...participant
|
|
|
|
};
|
|
|
|
|
2019-01-13 19:33:28 +00:00
|
|
|
if (participant.name) {
|
2019-01-15 11:28:07 +00:00
|
|
|
participantToUpdate.name = getNormalizedDisplayName(participant.name);
|
2019-01-13 19:33:28 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
return {
|
|
|
|
type: PARTICIPANT_UPDATED,
|
2019-01-15 11:28:07 +00:00
|
|
|
participant: participantToUpdate
|
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
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2017-11-21 17:38:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An array of names of participants that have joined the conference. The array
|
|
|
|
* is replaced with an empty array as notifications are displayed.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {string[]}
|
|
|
|
*/
|
|
|
|
let joinedParticipantsNames = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A throttled internal function that takes the internal list of participant
|
|
|
|
* names, {@code joinedParticipantsNames}, and triggers the display of a
|
|
|
|
* notification informing of their joining.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {Function}
|
|
|
|
*/
|
|
|
|
const _throttledNotifyParticipantConnected = throttle(dispatch => {
|
|
|
|
const joinedParticipantsCount = joinedParticipantsNames.length;
|
|
|
|
|
|
|
|
let notificationProps;
|
|
|
|
|
|
|
|
if (joinedParticipantsCount >= 3) {
|
|
|
|
notificationProps = {
|
|
|
|
titleArguments: {
|
|
|
|
name: joinedParticipantsNames[0],
|
|
|
|
count: joinedParticipantsCount - 1
|
|
|
|
},
|
|
|
|
titleKey: 'notify.connectedThreePlusMembers'
|
|
|
|
};
|
|
|
|
} else if (joinedParticipantsCount === 2) {
|
|
|
|
notificationProps = {
|
|
|
|
titleArguments: {
|
|
|
|
first: joinedParticipantsNames[0],
|
|
|
|
second: joinedParticipantsNames[1]
|
|
|
|
},
|
|
|
|
titleKey: 'notify.connectedTwoMembers'
|
|
|
|
};
|
|
|
|
} else if (joinedParticipantsCount) {
|
|
|
|
notificationProps = {
|
|
|
|
titleArguments: {
|
|
|
|
name: joinedParticipantsNames[0]
|
|
|
|
},
|
|
|
|
titleKey: 'notify.connectedOneMember'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (notificationProps) {
|
|
|
|
dispatch(
|
2017-12-11 18:33:09 +00:00
|
|
|
showNotification(notificationProps, 2500));
|
2017-11-21 17:38:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
joinedParticipantsNames = [];
|
|
|
|
|
|
|
|
}, 500, { leading: false });
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Queues the display of a notification of a participant having connected to
|
|
|
|
* the meeting. The notifications are batched so that quick consecutive
|
|
|
|
* connection events are shown in one notification.
|
|
|
|
*
|
|
|
|
* @param {string} displayName - The name of the participant that connected.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function showParticipantJoinedNotification(displayName) {
|
|
|
|
joinedParticipantsNames.push(
|
|
|
|
displayName || interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME);
|
|
|
|
|
2018-05-22 19:30:51 +00:00
|
|
|
return dispatch => _throttledNotifyParticipantConnected(dispatch);
|
2017-11-21 17:38:40 +00:00
|
|
|
}
|