Browse Source

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.
j8
Leonard Kim 8 years ago
parent
commit
955542f4a5
2 changed files with 34 additions and 1 deletions
  1. 14
    1
      conference.js
  2. 20
    0
      react/features/base/participants/actions.js

+ 14
- 1
conference.js View File

@@ -35,8 +35,10 @@ import {
35 35
 } from './react/features/base/lib-jitsi-meet';
36 36
 import { setVideoAvailable } from './react/features/base/media';
37 37
 import {
38
+    localParticipantConnectionStatusChanged,
38 39
     localParticipantRoleChanged,
39 40
     MAX_DISPLAY_NAME_LENGTH,
41
+    participantConnectionStatusChanged,
40 42
     participantJoined,
41 43
     participantLeft,
42 44
     participantRoleChanged,
@@ -56,6 +58,8 @@ import {
56 58
 } from './react/features/overlay';
57 59
 import { showDesktopSharingButton } from './react/features/toolbox';
58 60
 
61
+const { participantConnectionStatus } = JitsiMeetJS.constants;
62
+
59 63
 const ConnectionEvents = JitsiMeetJS.events.connection;
60 64
 const ConnectionErrors = JitsiMeetJS.errors.connection;
61 65
 
@@ -1542,7 +1546,10 @@ export default {
1542 1546
 
1543 1547
         room.on(
1544 1548
             ConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED,
1545
-            id => {
1549
+            (id, connectionStatus) => {
1550
+                APP.store.dispatch(participantConnectionStatusChanged(
1551
+                    id, connectionStatus));
1552
+
1546 1553
                 APP.UI.participantConnectionStatusChanged(id);
1547 1554
         });
1548 1555
         room.on(ConferenceEvents.DOMINANT_SPEAKER_CHANGED, (id) => {
@@ -1636,10 +1643,16 @@ export default {
1636 1643
         }
1637 1644
 
1638 1645
         room.on(ConferenceEvents.CONNECTION_INTERRUPTED, () => {
1646
+            APP.store.dispatch(localParticipantConnectionStatusChanged(
1647
+                participantConnectionStatus.INTERRUPTED));
1648
+
1639 1649
             APP.UI.showLocalConnectionInterrupted(true);
1640 1650
         });
1641 1651
 
1642 1652
         room.on(ConferenceEvents.CONNECTION_RESTORED, () => {
1653
+            APP.store.dispatch(localParticipantConnectionStatusChanged(
1654
+                participantConnectionStatus.ACTIVE));
1655
+
1643 1656
             APP.UI.showLocalConnectionInterrupted(false);
1644 1657
         });
1645 1658
 

+ 20
- 0
react/features/base/participants/actions.js View File

@@ -30,6 +30,26 @@ export function dominantSpeakerChanged(id) {
30 30
     };
31 31
 }
32 32
 
33
+/**
34
+ * Creates an action to signal the connection status of the local participant
35
+ * has changed.
36
+ *
37
+ * @param {string} connectionStatus - The current connection status of the local
38
+ * participant, as enumerated by the library's participantConnectionStatus
39
+ * constants.
40
+ * @returns {Function}
41
+ */
42
+export function localParticipantConnectionStatusChanged(connectionStatus) {
43
+    return (dispatch, getState) => {
44
+        const participant = getLocalParticipant(getState);
45
+
46
+        if (participant) {
47
+            return dispatch(participantConnectionStatusChanged(
48
+                participant.id, connectionStatus));
49
+        }
50
+    };
51
+}
52
+
33 53
 /**
34 54
  * Action to signal that the ID of local participant has changed. It happens
35 55
  * when the local participant joins a new conference or leaves an existing

Loading…
Cancel
Save