Move participant event handler to a platform generic location

This commit is contained in:
Bettenbuk Zoltan 2019-03-26 13:11:09 +01:00 committed by Saúl Ibarra Corretgé
parent b413457a4f
commit ce9744b9c3
2 changed files with 41 additions and 17 deletions

View File

@ -1919,21 +1919,6 @@ export default {
JitsiConferenceEvents.PARTICIPANT_PROPERTY_CHANGED,
(participant, name, oldValue, newValue) => {
switch (name) {
case 'features_screen-sharing': {
APP.store.dispatch(participantUpdated({
conference: room,
id: participant.getId(),
features: { 'screen-sharing': true }
}));
break;
}
case 'raisedHand':
APP.store.dispatch(participantUpdated({
conference: room,
id: participant.getId(),
raisedHand: newValue === 'true'
}));
break;
case 'remoteControlSessionStatus':
APP.UI.setRemoteControlActiveStatus(
participant.getId(),

View File

@ -1,14 +1,17 @@
// @flow
import UIEvents from '../../../../service/UI/UIEvents';
import { CALLING, INVITED } from '../../presence-status';
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app';
import {
CONFERENCE_WILL_JOIN,
forEachConference,
getCurrentConference
} from '../conference';
import { CALLING, INVITED } from '../../presence-status';
import { JitsiConferenceEvents } from '../lib-jitsi-meet';
import { MiddlewareRegistry, StateListenerRegistry } from '../redux';
import UIEvents from '../../../../service/UI/UIEvents';
import { playSound, registerSound, unregisterSound } from '../sounds';
import {
@ -185,6 +188,42 @@ StateListenerRegistry.register(
localParticipantIdChanged(LOCAL_PARTICIPANT_DEFAULT_ID));
});
/**
* Registers listeners for participant change events.
*/
StateListenerRegistry.register(
state => state['features/base/conference'].conference,
(conference, { dispatch }) => {
if (conference) {
// We joined a conference
conference.on(
JitsiConferenceEvents.PARTICIPANT_PROPERTY_CHANGED,
(participant, propertyName, oldValue, newValue) => {
switch (propertyName) {
case 'features_screen-sharing':
store.dispatch(participantUpdated({
conference,
id: participant.getId(),
features: { 'screen-sharing': true }
}));
break;
case 'raisedHand':
dispatch(participantUpdated({
conference,
id: participant.getId(),
raisedHand: newValue === 'true'
}));
break;
default:
// Ignore for now.
}
});
}
}
);
/**
* Initializes the local participant and signals that it joined.
*