Browse Source

Move participant event handler to a platform generic location

master
Bettenbuk Zoltan 6 years ago
parent
commit
ce9744b9c3
2 changed files with 41 additions and 17 deletions
  1. 0
    15
      conference.js
  2. 41
    2
      react/features/base/participants/middleware.js

+ 0
- 15
conference.js View File

1919
             JitsiConferenceEvents.PARTICIPANT_PROPERTY_CHANGED,
1919
             JitsiConferenceEvents.PARTICIPANT_PROPERTY_CHANGED,
1920
             (participant, name, oldValue, newValue) => {
1920
             (participant, name, oldValue, newValue) => {
1921
                 switch (name) {
1921
                 switch (name) {
1922
-                case 'features_screen-sharing': {
1923
-                    APP.store.dispatch(participantUpdated({
1924
-                        conference: room,
1925
-                        id: participant.getId(),
1926
-                        features: { 'screen-sharing': true }
1927
-                    }));
1928
-                    break;
1929
-                }
1930
-                case 'raisedHand':
1931
-                    APP.store.dispatch(participantUpdated({
1932
-                        conference: room,
1933
-                        id: participant.getId(),
1934
-                        raisedHand: newValue === 'true'
1935
-                    }));
1936
-                    break;
1937
                 case 'remoteControlSessionStatus':
1922
                 case 'remoteControlSessionStatus':
1938
                     APP.UI.setRemoteControlActiveStatus(
1923
                     APP.UI.setRemoteControlActiveStatus(
1939
                         participant.getId(),
1924
                         participant.getId(),

+ 41
- 2
react/features/base/participants/middleware.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
+import UIEvents from '../../../../service/UI/UIEvents';
4
+
5
+import { CALLING, INVITED } from '../../presence-status';
6
+
3
 import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app';
7
 import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app';
4
 import {
8
 import {
5
     CONFERENCE_WILL_JOIN,
9
     CONFERENCE_WILL_JOIN,
6
     forEachConference,
10
     forEachConference,
7
     getCurrentConference
11
     getCurrentConference
8
 } from '../conference';
12
 } from '../conference';
9
-import { CALLING, INVITED } from '../../presence-status';
13
+import { JitsiConferenceEvents } from '../lib-jitsi-meet';
10
 import { MiddlewareRegistry, StateListenerRegistry } from '../redux';
14
 import { MiddlewareRegistry, StateListenerRegistry } from '../redux';
11
-import UIEvents from '../../../../service/UI/UIEvents';
12
 import { playSound, registerSound, unregisterSound } from '../sounds';
15
 import { playSound, registerSound, unregisterSound } from '../sounds';
13
 
16
 
14
 import {
17
 import {
185
                 localParticipantIdChanged(LOCAL_PARTICIPANT_DEFAULT_ID));
188
                 localParticipantIdChanged(LOCAL_PARTICIPANT_DEFAULT_ID));
186
     });
189
     });
187
 
190
 
191
+/**
192
+ * Registers listeners for participant change events.
193
+ */
194
+StateListenerRegistry.register(
195
+    state => state['features/base/conference'].conference,
196
+    (conference, { dispatch }) => {
197
+        if (conference) {
198
+            // We joined a conference
199
+            conference.on(
200
+                JitsiConferenceEvents.PARTICIPANT_PROPERTY_CHANGED,
201
+                (participant, propertyName, oldValue, newValue) => {
202
+                    switch (propertyName) {
203
+                    case 'features_screen-sharing':
204
+                        store.dispatch(participantUpdated({
205
+                            conference,
206
+                            id: participant.getId(),
207
+                            features: { 'screen-sharing': true }
208
+                        }));
209
+                        break;
210
+                    case 'raisedHand':
211
+                        dispatch(participantUpdated({
212
+                            conference,
213
+                            id: participant.getId(),
214
+                            raisedHand: newValue === 'true'
215
+                        }));
216
+                        break;
217
+                    default:
218
+
219
+                        // Ignore for now.
220
+                    }
221
+
222
+                });
223
+        }
224
+    }
225
+);
226
+
188
 /**
227
 /**
189
  * Initializes the local participant and signals that it joined.
228
  * Initializes the local participant and signals that it joined.
190
  *
229
  *

Loading…
Cancel
Save