feat(speaker-status): update speaker status in redux

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.
This commit is contained in:
Leonard Kim 2017-07-12 17:26:10 -07:00 committed by Paweł Domas
parent 68d40b4fa4
commit 955542f4a5
2 changed files with 34 additions and 1 deletions

View File

@ -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,
@ -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;
@ -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) => {
@ -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);
});

View File

@ -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