Skip to content

Commit

Permalink
feat(speaker-status): update speaker status in redux
Browse files Browse the repository at this point in the history
The speakerStatus field already exists as part of the objects
in the participant reducer. When the library updates the
connection status of a user, plumb that update through to redux.
  • Loading branch information
virtuacoplenny authored and paweldomas committed Jul 21, 2017
1 parent 68d40b4 commit 955542f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
15 changes: 14 additions & 1 deletion conference.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ import {
} from './react/features/base/lib-jitsi-meet';
import { setVideoAvailable } from './react/features/base/media';
import {
localParticipantConnectionStatusChanged,
localParticipantRoleChanged,
MAX_DISPLAY_NAME_LENGTH,
participantConnectionStatusChanged,
participantJoined,
participantLeft,
participantRoleChanged,
Expand All @@ -56,6 +58,8 @@ import {
} from './react/features/overlay';
import { showDesktopSharingButton } from './react/features/toolbox';

const { participantConnectionStatus } = JitsiMeetJS.constants;

const ConnectionEvents = JitsiMeetJS.events.connection;
const ConnectionErrors = JitsiMeetJS.errors.connection;

Expand Down Expand Up @@ -1542,7 +1546,10 @@ export default {

room.on(
ConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED,
id => {
(id, connectionStatus) => {
APP.store.dispatch(participantConnectionStatusChanged(
id, connectionStatus));

APP.UI.participantConnectionStatusChanged(id);
});
room.on(ConferenceEvents.DOMINANT_SPEAKER_CHANGED, (id) => {
Expand Down Expand Up @@ -1636,10 +1643,16 @@ export default {
}

room.on(ConferenceEvents.CONNECTION_INTERRUPTED, () => {
APP.store.dispatch(localParticipantConnectionStatusChanged(
participantConnectionStatus.INTERRUPTED));

APP.UI.showLocalConnectionInterrupted(true);
});

room.on(ConferenceEvents.CONNECTION_RESTORED, () => {
APP.store.dispatch(localParticipantConnectionStatusChanged(
participantConnectionStatus.ACTIVE));

APP.UI.showLocalConnectionInterrupted(false);
});

Expand Down
20 changes: 20 additions & 0 deletions react/features/base/participants/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ export function dominantSpeakerChanged(id) {
};
}

/**
* 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(
participant.id, connectionStatus));
}
};
}

/**
* 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
Expand Down

0 comments on commit 955542f

Please sign in to comment.