|
@@ -39,6 +39,35 @@ declare var APP: Object;
|
39
|
39
|
const PARTICIPANT_PROPS_TO_OMIT_WHEN_UPDATE
|
40
|
40
|
= [ 'dominantSpeaker', 'id', 'local', 'pinned' ];
|
41
|
41
|
|
|
42
|
+/**
|
|
43
|
+ * Listen for actions which add, remove, or update the set of participants in
|
|
44
|
+ * the conference.
|
|
45
|
+ *
|
|
46
|
+ * @param {Participant[]} state - List of participants to be modified.
|
|
47
|
+ * @param {Object} action - Action object.
|
|
48
|
+ * @param {string} action.type - Type of action.
|
|
49
|
+ * @param {Participant} action.participant - Information about participant to be
|
|
50
|
+ * added/removed/modified.
|
|
51
|
+ * @returns {Participant[]}
|
|
52
|
+ */
|
|
53
|
+ReducerRegistry.register('features/base/participants', (state = [], action) => {
|
|
54
|
+ switch (action.type) {
|
|
55
|
+ case DOMINANT_SPEAKER_CHANGED:
|
|
56
|
+ case PARTICIPANT_ID_CHANGED:
|
|
57
|
+ case PARTICIPANT_UPDATED:
|
|
58
|
+ case PIN_PARTICIPANT:
|
|
59
|
+ return state.map(p => _participant(p, action));
|
|
60
|
+
|
|
61
|
+ case PARTICIPANT_JOINED:
|
|
62
|
+ return [ ...state, _participantJoined(action) ];
|
|
63
|
+
|
|
64
|
+ case PARTICIPANT_LEFT:
|
|
65
|
+ return state.filter(p => p.id !== action.participant.id);
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ return state;
|
|
69
|
+});
|
|
70
|
+
|
42
|
71
|
/**
|
43
|
72
|
* Reducer function for a single participant.
|
44
|
73
|
*
|
|
@@ -67,52 +96,6 @@ function _participant(state: Object = {}, action) {
|
67
|
96
|
}
|
68
|
97
|
break;
|
69
|
98
|
|
70
|
|
- case PARTICIPANT_JOINED: {
|
71
|
|
- const { participant } = action; // eslint-disable-line no-shadow
|
72
|
|
- const {
|
73
|
|
- avatarURL,
|
74
|
|
- connectionStatus,
|
75
|
|
- dominantSpeaker,
|
76
|
|
- email,
|
77
|
|
- isBot,
|
78
|
|
- local,
|
79
|
|
- name,
|
80
|
|
- pinned,
|
81
|
|
- role
|
82
|
|
- } = participant;
|
83
|
|
- let { avatarID, id } = participant;
|
84
|
|
-
|
85
|
|
- // avatarID
|
86
|
|
- //
|
87
|
|
- // TODO Get the avatarID of the local participant from localStorage.
|
88
|
|
- if (!avatarID && local) {
|
89
|
|
- avatarID = randomHexString(32);
|
90
|
|
- }
|
91
|
|
-
|
92
|
|
- // id
|
93
|
|
- //
|
94
|
|
- // XXX The situation of not having an ID for a remote participant should
|
95
|
|
- // not happen. Maybe we should raise an error in this case or generate a
|
96
|
|
- // random ID.
|
97
|
|
- if (!id && local) {
|
98
|
|
- id = LOCAL_PARTICIPANT_DEFAULT_ID;
|
99
|
|
- }
|
100
|
|
-
|
101
|
|
- return {
|
102
|
|
- avatarID,
|
103
|
|
- avatarURL,
|
104
|
|
- connectionStatus,
|
105
|
|
- dominantSpeaker: dominantSpeaker || false,
|
106
|
|
- email,
|
107
|
|
- id,
|
108
|
|
- isBot,
|
109
|
|
- local: local || false,
|
110
|
|
- name,
|
111
|
|
- pinned: pinned || false,
|
112
|
|
- role: role || PARTICIPANT_ROLE.NONE
|
113
|
|
- };
|
114
|
|
- }
|
115
|
|
-
|
116
|
99
|
case PARTICIPANT_UPDATED: {
|
117
|
100
|
const { participant } = action; // eslint-disable-line no-shadow
|
118
|
101
|
let { id } = participant;
|
|
@@ -147,31 +130,60 @@ function _participant(state: Object = {}, action) {
|
147
|
130
|
}
|
148
|
131
|
|
149
|
132
|
/**
|
150
|
|
- * Listen for actions which add, remove, or update the set of participants in
|
151
|
|
- * the conference.
|
|
133
|
+ * Reduces a specific redux action of type {@link PARTICIPANT_JOINED} in the
|
|
134
|
+ * feature base/participants.
|
152
|
135
|
*
|
153
|
|
- * @param {Participant[]} state - List of participants to be modified.
|
154
|
|
- * @param {Object} action - Action object.
|
155
|
|
- * @param {string} action.type - Type of action.
|
156
|
|
- * @param {Participant} action.participant - Information about participant to be
|
157
|
|
- * added/removed/modified.
|
158
|
|
- * @returns {Participant[]}
|
|
136
|
+ * @param {Action} action - The redux action of type {@code PARTICIPANT_JOINED}
|
|
137
|
+ * to reduce.
|
|
138
|
+ * @private
|
|
139
|
+ * @returns {Object} The new participant derived from the payload of the
|
|
140
|
+ * specified {@code action} to be added into the redux state of the feature
|
|
141
|
+ * base/participants after the reduction of the specified
|
|
142
|
+ * {@code action}.
|
159
|
143
|
*/
|
160
|
|
-ReducerRegistry.register('features/base/participants', (state = [], action) => {
|
161
|
|
- switch (action.type) {
|
162
|
|
- case DOMINANT_SPEAKER_CHANGED:
|
163
|
|
- case PARTICIPANT_ID_CHANGED:
|
164
|
|
- case PARTICIPANT_UPDATED:
|
165
|
|
- case PIN_PARTICIPANT:
|
166
|
|
- return state.map(p => _participant(p, action));
|
167
|
|
-
|
168
|
|
- case PARTICIPANT_JOINED:
|
169
|
|
- return [ ...state, _participant(undefined, action) ];
|
|
144
|
+function _participantJoined({ participant }) {
|
|
145
|
+ const {
|
|
146
|
+ avatarURL,
|
|
147
|
+ connectionStatus,
|
|
148
|
+ dominantSpeaker,
|
|
149
|
+ email,
|
|
150
|
+ isBot,
|
|
151
|
+ local,
|
|
152
|
+ name,
|
|
153
|
+ pinned,
|
|
154
|
+ role
|
|
155
|
+ } = participant;
|
|
156
|
+ let { avatarID, conference, id } = participant;
|
|
157
|
+
|
|
158
|
+ if (local) {
|
|
159
|
+ // avatarID
|
|
160
|
+ //
|
|
161
|
+ // TODO Get the avatarID of the local participant from localStorage.
|
|
162
|
+ avatarID || (avatarID = randomHexString(32));
|
170
|
163
|
|
171
|
|
- case PARTICIPANT_LEFT:
|
172
|
|
- return state.filter(p => p.id !== action.participant.id);
|
|
164
|
+ // conference
|
|
165
|
+ //
|
|
166
|
+ // XXX The local participant is not identified in association with a
|
|
167
|
+ // JitsiConference because it is identified by the very fact that it is
|
|
168
|
+ // the local participant.
|
|
169
|
+ conference = undefined;
|
173
|
170
|
|
174
|
|
- default:
|
175
|
|
- return state;
|
|
171
|
+ // id
|
|
172
|
+ id || (id = LOCAL_PARTICIPANT_DEFAULT_ID);
|
176
|
173
|
}
|
177
|
|
-});
|
|
174
|
+
|
|
175
|
+ return {
|
|
176
|
+ avatarID,
|
|
177
|
+ avatarURL,
|
|
178
|
+ conference,
|
|
179
|
+ connectionStatus,
|
|
180
|
+ dominantSpeaker: dominantSpeaker || false,
|
|
181
|
+ email,
|
|
182
|
+ id,
|
|
183
|
+ isBot,
|
|
184
|
+ local: local || false,
|
|
185
|
+ name,
|
|
186
|
+ pinned: pinned || false,
|
|
187
|
+ role: role || PARTICIPANT_ROLE.NONE
|
|
188
|
+ };
|
|
189
|
+}
|