Bladeren bron

Comply w/ coding style

j8
Lyubo Marinov 8 jaren geleden
bovenliggende
commit
23ddce122b

+ 12
- 14
conference.js Bestand weergeven

21
 import EventEmitter from "events";
21
 import EventEmitter from "events";
22
 
22
 
23
 import {
23
 import {
24
-    CONFERENCE_JOINED,
24
+    conferenceJoined,
25
     conferenceFailed,
25
     conferenceFailed,
26
     conferenceLeft
26
     conferenceLeft
27
 } from './react/features/base/conference';
27
 } from './react/features/base/conference';
28
 import {
28
 import {
29
     isFatalJitsiConnectionError
29
     isFatalJitsiConnectionError
30
 } from './react/features/base/lib-jitsi-meet';
30
 } from './react/features/base/lib-jitsi-meet';
31
-import {
32
-    mediaPermissionPromptVisibilityChanged,
33
-    suspendDetected
34
-} from './react/features/overlay';
35
-
36
 import {
31
 import {
37
     changeParticipantAvatarID,
32
     changeParticipantAvatarID,
38
     changeParticipantAvatarURL,
33
     changeParticipantAvatarURL,
41
     participantLeft,
36
     participantLeft,
42
     participantRoleChanged
37
     participantRoleChanged
43
 } from './react/features/base/participants';
38
 } from './react/features/base/participants';
39
+import {
40
+    mediaPermissionPromptVisibilityChanged,
41
+    suspendDetected
42
+} from './react/features/overlay';
44
 
43
 
45
 const ConnectionEvents = JitsiMeetJS.events.connection;
44
 const ConnectionEvents = JitsiMeetJS.events.connection;
46
 const ConnectionErrors = JitsiMeetJS.errors.connection;
45
 const ConnectionErrors = JitsiMeetJS.errors.connection;
164
 }
163
 }
165
 
164
 
166
 /**
165
 /**
167
- * Setups initially the properties for the local participant - email, avatarId,
168
- * avatarUrl, displayName, etc.
166
+ * Sets up initially the properties of the local participant - email, avatarID,
167
+ * avatarURL, displayName, etc.
169
  */
168
  */
170
 function _setupLocalParticipantProperties() {
169
 function _setupLocalParticipantProperties() {
171
     const email = APP.settings.getEmail();
170
     const email = APP.settings.getEmail();
174
     const avatarUrl = APP.settings.getAvatarUrl();
173
     const avatarUrl = APP.settings.getAvatarUrl();
175
     avatarUrl && sendData(commands.AVATAR_URL, avatarUrl);
174
     avatarUrl && sendData(commands.AVATAR_URL, avatarUrl);
176
 
175
 
177
-    if(!email && !avatarUrl) {
176
+    if (!email && !avatarUrl) {
178
         sendData(commands.AVATAR_ID, APP.settings.getAvatarId());
177
         sendData(commands.AVATAR_ID, APP.settings.getAvatarId());
179
     }
178
     }
180
 
179
 
1138
     _setupListeners () {
1137
     _setupListeners () {
1139
         // add local streams when joined to the conference
1138
         // add local streams when joined to the conference
1140
         room.on(ConferenceEvents.CONFERENCE_JOINED, () => {
1139
         room.on(ConferenceEvents.CONFERENCE_JOINED, () => {
1141
-            APP.store.dispatch({
1142
-                type: CONFERENCE_JOINED,
1143
-                conference: room
1144
-            });
1140
+            APP.store.dispatch(conferenceJoined(room));
1141
+
1145
             APP.UI.mucJoined();
1142
             APP.UI.mucJoined();
1146
             APP.API.notifyConferenceJoined(APP.conference.roomName);
1143
             APP.API.notifyConferenceJoined(APP.conference.roomName);
1147
             APP.UI.markVideoInterrupted(false);
1144
             APP.UI.markVideoInterrupted(false);
1148
         });
1145
         });
1149
 
1146
 
1150
-        room.on(ConferenceEvents.CONFERENCE_LEFT,
1147
+        room.on(
1148
+            ConferenceEvents.CONFERENCE_LEFT,
1151
             (...args) => APP.store.dispatch(conferenceLeft(room, ...args)));
1149
             (...args) => APP.store.dispatch(conferenceLeft(room, ...args)));
1152
 
1150
 
1153
         room.on(
1151
         room.on(

+ 6
- 1
modules/UI/avatar/Avatar.js Bestand weergeven

91
             user = users[userId];
91
             user = users[userId];
92
         }
92
         }
93
 
93
 
94
-        return getAvatarURL(userId, user);
94
+        return getAvatarURL({
95
+            avatarID: user ? user.avatarId : undefined,
96
+            avatarURL: user ? user.avatarUrl : undefined,
97
+            email: user ? user.email : undefined,
98
+            id: userId
99
+        });
95
     }
100
     }
96
 };
101
 };

+ 16
- 7
react/features/app/components/AbstractApp.js Bestand weergeven

1
-/* global APP */
2
-
3
 import React, { Component } from 'react';
1
 import React, { Component } from 'react';
4
 import { I18nextProvider } from 'react-i18next';
2
 import { I18nextProvider } from 'react-i18next';
5
 import { Provider } from 'react-redux';
3
 import { Provider } from 'react-redux';
20
     appWillUnmount
18
     appWillUnmount
21
 } from '../actions';
19
 } from '../actions';
22
 
20
 
21
+declare var APP: Object;
22
+
23
 /**
23
 /**
24
  * Base (abstract) class for main App component.
24
  * Base (abstract) class for main App component.
25
  *
25
  *
78
 
78
 
79
         dispatch(appWillMount(this));
79
         dispatch(appWillMount(this));
80
 
80
 
81
-        dispatch(localParticipantJoined({
82
-            avatarId: APP.settings.getAvatarId(),
83
-            avatarUrl: APP.settings.getAvatarUrl(),
84
-            email: APP.settings.getEmail()
85
-        }));
81
+        // FIXME I believe it makes more sense for a middleware to dispatch
82
+        // localParticipantJoined on APP_WILL_MOUNT because the order of actions
83
+        // is important, not the call site. Moreover, we've got localParticipant
84
+        // business logic in the React Component (i.e. UI) AbstractApp now.
85
+        let localParticipant;
86
+
87
+        if (typeof APP !== 'undefined') {
88
+            localParticipant = {
89
+                avatarID: APP.settings.getAvatarId(),
90
+                avatarURL: APP.settings.getAvatarUrl(),
91
+                email: APP.settings.getEmail()
92
+            };
93
+        }
94
+        dispatch(localParticipantJoined(localParticipant));
86
 
95
 
87
         // If a URL was explicitly specified to this React Component, then open
96
         // If a URL was explicitly specified to this React Component, then open
88
         // it; otherwise, use a default.
97
         // it; otherwise, use a default.

+ 2
- 2
react/features/base/conference/actions.js Bestand weergeven

35
             (...args) => dispatch(conferenceFailed(conference, ...args)));
35
             (...args) => dispatch(conferenceFailed(conference, ...args)));
36
     conference.on(
36
     conference.on(
37
             JitsiConferenceEvents.CONFERENCE_JOINED,
37
             JitsiConferenceEvents.CONFERENCE_JOINED,
38
-            (...args) => dispatch(_conferenceJoined(conference, ...args)));
38
+            (...args) => dispatch(conferenceJoined(conference, ...args)));
39
     conference.on(
39
     conference.on(
40
             JitsiConferenceEvents.CONFERENCE_LEFT,
40
             JitsiConferenceEvents.CONFERENCE_LEFT,
41
             (...args) => dispatch(conferenceLeft(conference, ...args)));
41
             (...args) => dispatch(conferenceLeft(conference, ...args)));
103
  * joined by the local participant.
103
  * joined by the local participant.
104
  * @returns {Function}
104
  * @returns {Function}
105
  */
105
  */
106
-function _conferenceJoined(conference) {
106
+export function conferenceJoined(conference) {
107
     return (dispatch, getState) => {
107
     return (dispatch, getState) => {
108
         const localTracks
108
         const localTracks
109
             = getState()['features/base/tracks']
109
             = getState()['features/base/tracks']

+ 52
- 52
react/features/base/participants/actions.js Bestand weergeven

9
 import { getLocalParticipant } from './functions';
9
 import { getLocalParticipant } from './functions';
10
 
10
 
11
 /**
11
 /**
12
- * Action to update a participant's avatar id.
12
+ * Action to update a participant's avatar ID.
13
  *
13
  *
14
- * @param {string} id - Participant's id.
15
- * @param {string} avatarId - Participant's avatar id.
14
+ * @param {string} id - Participant's ID.
15
+ * @param {string} avatarID - Participant's avatar ID.
16
  * @returns {{
16
  * @returns {{
17
- *      type: PARTICIPANT_UPDATED,
18
- *      participant: {
19
- *          id: string,
20
- *          avatarId: string,
21
- *      }
17
+ *     type: PARTICIPANT_UPDATED,
18
+ *     participant: {
19
+ *         id: string,
20
+ *         avatarID: string,
21
+ *     }
22
  * }}
22
  * }}
23
  */
23
  */
24
-export function changeParticipantAvatarID(id, avatarId) {
24
+export function changeParticipantAvatarID(id, avatarID) {
25
     return {
25
     return {
26
         type: PARTICIPANT_UPDATED,
26
         type: PARTICIPANT_UPDATED,
27
         participant: {
27
         participant: {
28
             id,
28
             id,
29
-            avatarId
29
+            avatarID
30
         }
30
         }
31
     };
31
     };
32
 }
32
 }
34
 /**
34
 /**
35
  * Action to update a participant's avatar URL.
35
  * Action to update a participant's avatar URL.
36
  *
36
  *
37
- * @param {string} id - Participant's id.
38
- * @param {string} url - Participant's avatar url.
37
+ * @param {string} id - Participant's ID.
38
+ * @param {string} avatarURL - Participant's avatar URL.
39
  * @returns {{
39
  * @returns {{
40
- *      type: PARTICIPANT_UPDATED,
41
- *      participant: {
42
- *          id: string,
43
- *          url: string,
44
- *      }
40
+ *     type: PARTICIPANT_UPDATED,
41
+ *     participant: {
42
+ *         id: string,
43
+ *         avatarURL: string,
44
+ *     }
45
  * }}
45
  * }}
46
  */
46
  */
47
-export function changeParticipantAvatarURL(id, url) {
47
+export function changeParticipantAvatarURL(id, avatarURL) {
48
     return {
48
     return {
49
         type: PARTICIPANT_UPDATED,
49
         type: PARTICIPANT_UPDATED,
50
         participant: {
50
         participant: {
51
             id,
51
             id,
52
-            url
52
+            avatarURL
53
         }
53
         }
54
     };
54
     };
55
 }
55
 }
57
 /**
57
 /**
58
  * Action to update a participant's email.
58
  * Action to update a participant's email.
59
  *
59
  *
60
- * @param {string} id - Participant's id.
60
+ * @param {string} id - Participant's ID.
61
  * @param {string} email - Participant's email.
61
  * @param {string} email - Participant's email.
62
  * @returns {{
62
  * @returns {{
63
- *      type: PARTICIPANT_UPDATED,
64
- *      participant: {
65
- *          id: string,
66
- *          email: string
67
- *      }
63
+ *     type: PARTICIPANT_UPDATED,
64
+ *     participant: {
65
+ *         id: string,
66
+ *         email: string
67
+ *     }
68
  * }}
68
  * }}
69
  */
69
  */
70
 export function changeParticipantEmail(id, email) {
70
 export function changeParticipantEmail(id, email) {
80
 /**
80
 /**
81
  * Create an action for when dominant speaker changes.
81
  * Create an action for when dominant speaker changes.
82
  *
82
  *
83
- * @param {string} id - Participant id.
83
+ * @param {string} id - Participant's ID.
84
  * @returns {{
84
  * @returns {{
85
- *      type: DOMINANT_SPEAKER_CHANGED,
86
- *      participant: {
87
- *          id: string
88
- *      }
85
+ *     type: DOMINANT_SPEAKER_CHANGED,
86
+ *     participant: {
87
+ *         id: string
88
+ *     }
89
  * }}
89
  * }}
90
  */
90
  */
91
 export function dominantSpeakerChanged(id) {
91
 export function dominantSpeakerChanged(id) {
103
  *
103
  *
104
  * @param {string} id - New ID for local participant.
104
  * @param {string} id - New ID for local participant.
105
  * @returns {{
105
  * @returns {{
106
- *      type: PARTICIPANT_ID_CHANGED,
107
- *      newValue: string,
108
- *      oldValue: string
106
+ *     type: PARTICIPANT_ID_CHANGED,
107
+ *     newValue: string,
108
+ *     oldValue: string
109
  * }}
109
  * }}
110
  */
110
  */
111
 export function localParticipantIdChanged(id) {
111
 export function localParticipantIdChanged(id) {
127
  *
127
  *
128
  * @param {Participant} participant={} - Information about participant.
128
  * @param {Participant} participant={} - Information about participant.
129
  * @returns {{
129
  * @returns {{
130
- *      type: PARTICIPANT_JOINED,
131
- *      participant: Participant
130
+ *     type: PARTICIPANT_JOINED,
131
+ *     participant: Participant
132
  * }}
132
  * }}
133
  */
133
  */
134
 export function localParticipantJoined(participant = {}) {
134
 export function localParticipantJoined(participant = {}) {
170
 }
170
 }
171
 
171
 
172
 /**
172
 /**
173
- * Action to handle case when participant lefts.
173
+ * Action to signal that a participant has left.
174
  *
174
  *
175
- * @param {string} id - Participant id.
175
+ * @param {string} id - Participant's ID.
176
  * @returns {{
176
  * @returns {{
177
- *      type: PARTICIPANT_LEFT,
178
- *      participant: {
179
- *          id: string
180
- *      }
177
+ *     type: PARTICIPANT_LEFT,
178
+ *     participant: {
179
+ *         id: string
180
+ *     }
181
  * }}
181
  * }}
182
  */
182
  */
183
 export function participantLeft(id) {
183
 export function participantLeft(id) {
190
 }
190
 }
191
 
191
 
192
 /**
192
 /**
193
- * Action to handle case when participant's role changes.
193
+ * Action to signal that a participant's role has changed.
194
  *
194
  *
195
- * @param {string} id - Participant id.
195
+ * @param {string} id - Participant's ID.
196
  * @param {PARTICIPANT_ROLE} role - Participant's new role.
196
  * @param {PARTICIPANT_ROLE} role - Participant's new role.
197
  * @returns {{
197
  * @returns {{
198
- *      type: PARTICIPANT_UPDATED,
199
- *      participant: {
200
- *          id: string,
201
- *          role: PARTICIPANT_ROLE
202
- *      }
198
+ *     type: PARTICIPANT_UPDATED,
199
+ *     participant: {
200
+ *         id: string,
201
+ *         role: PARTICIPANT_ROLE
202
+ *     }
203
  * }}
203
  * }}
204
  */
204
  */
205
 export function participantRoleChanged(id, role) {
205
 export function participantRoleChanged(id, role) {
218
  * @param {string|null} id - The ID of the conference participant to pin or null
218
  * @param {string|null} id - The ID of the conference participant to pin or null
219
  * if none of the conference's participants are to be pinned.
219
  * if none of the conference's participants are to be pinned.
220
  * @returns {{
220
  * @returns {{
221
- *      type: PIN_PARTICIPANT,
222
- *      participant: {
223
- *          id: string
224
- *      }
221
+ *     type: PIN_PARTICIPANT,
222
+ *     participant: {
223
+ *         id: string
224
+ *     }
225
  * }}
225
  * }}
226
  */
226
  */
227
 export function pinParticipant(id) {
227
 export function pinParticipant(id) {

+ 1
- 4
react/features/base/participants/components/Avatar.web.js Bestand weergeven

24
      * @inheritdoc
24
      * @inheritdoc
25
      */
25
      */
26
     render() {
26
     render() {
27
-        return (
28
-            <img
29
-                src = { this.props.uri } />
30
-        );
27
+        return <img src = { this.props.uri } />;
31
     }
28
     }
32
 }
29
 }

+ 62
- 69
react/features/base/participants/functions.js Bestand weergeven

1
-/* global MD5 */
2
-
3
 declare var config: Object;
1
 declare var config: Object;
4
 declare var interfaceConfig: Object;
2
 declare var interfaceConfig: Object;
3
+declare var MD5: Object;
4
+
5
+/**
6
+ * Returns the URL of the image for the avatar of a specific participant.
7
+ *
8
+ * @param {Participant} [participant] - The participant to return the avatar URL
9
+ * of.
10
+ * @param {string} [participant.avatarID] - Participant's avatar ID.
11
+ * @param {string} [participant.avatarURL] - Participant's avatar URL.
12
+ * @param {string} [participant.email] - Participant's e-mail address.
13
+ * @param {string} [participant.id] - Participant's ID.
14
+ * @returns {string} The URL of the image for the avatar of the specified
15
+ * participant.
16
+ *
17
+ * @public
18
+ */
19
+export function getAvatarURL(participant) {
20
+    // If disableThirdPartyRequests disables third-party avatar services, we are
21
+    // restricted to a stock image of ours.
22
+    if (typeof config === 'object' && config.disableThirdPartyRequests) {
23
+        return 'images/avatar2.png';
24
+    }
25
+
26
+    const { avatarID, avatarURL, email, id } = participant;
27
+
28
+    // If an avatarURL is specified, then obviously there's nothing to generate.
29
+    if (avatarURL) {
30
+        return avatarURL;
31
+    }
32
+
33
+    let key = email || avatarID;
34
+    let urlPrefix;
35
+    let urlSuffix;
36
+
37
+    // If the ID looks like an e-mail address, we'll use Gravatar because it
38
+    // supports e-mail addresses.
39
+    if (key && key.indexOf('@') > 0) {
40
+        urlPrefix = 'https://www.gravatar.com/avatar/';
41
+        urlSuffix = '?d=wavatar&size=200';
42
+    } else {
43
+        // Otherwise, we do not have much a choice but a random avatar (fetched
44
+        // from a configured avatar service).
45
+        if (!key) {
46
+            key = id;
47
+        }
48
+
49
+        // The deployment is allowed to choose the avatar service which is to
50
+        // generate the random avatars.
51
+        urlPrefix
52
+            = typeof interfaceConfig === 'object'
53
+                && interfaceConfig.RANDOM_AVATAR_URL_PREFIX;
54
+        if (urlPrefix) {
55
+            urlSuffix = interfaceConfig.RANDOM_AVATAR_URL_SUFFIX;
56
+        } else {
57
+            // Otherwise, use a default (of course).
58
+            urlPrefix = 'https://api.adorable.io/avatars/200/';
59
+            urlSuffix = '.png';
60
+        }
61
+    }
62
+
63
+    return urlPrefix + MD5.hexdigest(key.trim().toLowerCase()) + urlSuffix;
64
+}
5
 
65
 
6
 /**
66
 /**
7
  * Returns local participant from Redux state.
67
  * Returns local participant from Redux state.
50
 
110
 
51
     return participants || [];
111
     return participants || [];
52
 }
112
 }
53
-
54
-/**
55
- * Returns the URL of the image for the avatar of a particular participant
56
- * identified by their id and/or e-mail address.
57
- *
58
- * @param {string} [participantId] - Participant's id.
59
- * @param {Object} [options] - The optional arguments.
60
- * @param {string} [options.avatarId] - Participant's avatar id.
61
- * @param {string} [options.avatarUrl] - Participant's avatar url.
62
- * @param {string} [options.email] - Participant's email.
63
- * @returns {string} The URL of the image for the avatar of the participant
64
- * identified by the specified participantId and/or email.
65
- *
66
- * @public
67
- */
68
-export function getAvatarURL(participantId, options = {}) {
69
-    // If disableThirdPartyRequests is enabled we shouldn't use third party
70
-    // avatar services, we are returning one of our images.
71
-    if (typeof config === 'object' && config.disableThirdPartyRequests) {
72
-        return 'images/avatar2.png';
73
-    }
74
-
75
-    const { avatarId, avatarUrl, email } = options;
76
-
77
-    // If we have avatarUrl we don't need to generate new one.
78
-    if (avatarUrl) {
79
-        return avatarUrl;
80
-    }
81
-
82
-    let avatarKey = null;
83
-
84
-    if (email) {
85
-        avatarKey = email;
86
-    } else {
87
-        avatarKey = avatarId;
88
-    }
89
-
90
-    // If the ID looks like an email, we'll use gravatar.
91
-    // Otherwise, it's a random avatar, and we'll use the configured
92
-    // URL.
93
-    const isEmail = avatarKey && avatarKey.indexOf('@') > 0;
94
-
95
-    if (!avatarKey) {
96
-        avatarKey = participantId;
97
-    }
98
-
99
-    avatarKey = MD5.hexdigest(avatarKey.trim().toLowerCase());
100
-
101
-    let urlPref = null;
102
-    let urlSuf = null;
103
-
104
-    // gravatar doesn't support random avatars that's why we need to use other
105
-    // services for the use case when the email is undefined.
106
-    if (isEmail) {
107
-        urlPref = 'https://www.gravatar.com/avatar/';
108
-        urlSuf = '?d=wavatar&size=200';
109
-    } else if (typeof interfaceConfig === 'object'
110
-        && interfaceConfig.RANDOM_AVATAR_URL_PREFIX) { // custom avatar service
111
-        urlPref = interfaceConfig.RANDOM_AVATAR_URL_PREFIX;
112
-        urlSuf = interfaceConfig.RANDOM_AVATAR_URL_SUFFIX;
113
-    } else { // default avatar service
114
-        urlPref = 'https://api.adorable.io/avatars/200/';
115
-        urlSuf = '.png';
116
-    }
117
-
118
-    return urlPref + avatarKey + urlSuf;
119
-}

+ 45
- 42
react/features/base/participants/reducer.js Bestand weergeven

63
     case PARTICIPANT_ID_CHANGED:
63
     case PARTICIPANT_ID_CHANGED:
64
         if (state.id === action.oldValue) {
64
         if (state.id === action.oldValue) {
65
             const id = action.newValue;
65
             const id = action.newValue;
66
-            const { avatarId, avatarUrl, email } = state;
67
-
68
-            return {
66
+            const newState = {
69
                 ...state,
67
                 ...state,
70
-                id,
71
-                avatar: state.avatar || getAvatarURL(id, {
72
-                    avatarId,
73
-                    avatarUrl,
74
-                    email
75
-                })
68
+                id
76
             };
69
             };
70
+
71
+            if (!newState.avatar) {
72
+                newState.avatar = getAvatarURL(newState);
73
+            }
74
+
75
+            return newState;
77
         }
76
         }
78
         break;
77
         break;
79
 
78
 
80
     case PARTICIPANT_JOINED: {
79
     case PARTICIPANT_JOINED: {
81
         const participant = action.participant; // eslint-disable-line no-shadow
80
         const participant = action.participant; // eslint-disable-line no-shadow
81
+        const { avatar, dominantSpeaker, email, local, pinned, role }
82
+            = participant;
83
+        let { id, name } = participant;
84
+
85
+        // id
86
+        //
82
         // XXX The situation of not having an ID for a remote participant should
87
         // XXX The situation of not having an ID for a remote participant should
83
         // not happen. Maybe we should raise an error in this case or generate a
88
         // not happen. Maybe we should raise an error in this case or generate a
84
         // random ID.
89
         // random ID.
85
-        const id
86
-            = participant.id
87
-                || (participant.local && LOCAL_PARTICIPANT_DEFAULT_ID);
88
-        const { avatarId, avatarUrl, email } = participant;
89
-        const avatar
90
-            = participant.avatar
91
-                || getAvatarURL(id, {
92
-                    avatarId,
93
-                    avatarUrl,
94
-                    email
95
-                });
96
-
97
-        // TODO Get these names from config/localized.
98
-        const name
99
-            = participant.name || (participant.local ? 'me' : 'Fellow Jitster');
100
-
101
-        return {
90
+        if (!id && local) {
91
+            id = LOCAL_PARTICIPANT_DEFAULT_ID;
92
+        }
93
+
94
+        // name
95
+        if (!name) {
96
+            // TODO Get the from config and/or localized.
97
+            name = local ? 'me' : 'Fellow Jitster';
98
+        }
99
+
100
+        const newState = {
102
             avatar,
101
             avatar,
102
+            dominantSpeaker: dominantSpeaker || false,
103
             email,
103
             email,
104
             id,
104
             id,
105
-            local: participant.local || false,
105
+            local: local || false,
106
             name,
106
             name,
107
-            pinned: participant.pinned || false,
108
-            role: participant.role || PARTICIPANT_ROLE.NONE,
109
-            dominantSpeaker: participant.dominantSpeaker || false
107
+            pinned: pinned || false,
108
+            role: role || PARTICIPANT_ROLE.NONE
110
         };
109
         };
110
+
111
+        if (!newState.avatar) {
112
+            newState.avatar = getAvatarURL(newState);
113
+        }
114
+
115
+        return newState;
111
     }
116
     }
112
 
117
 
113
-    case PARTICIPANT_UPDATED:
114
-        if (state.id === action.participant.id) {
118
+    case PARTICIPANT_UPDATED: {
119
+        const participant = action.participant; // eslint-disable-line no-shadow
120
+        const { id } = participant;
121
+
122
+        if (state.id === id) {
115
             const newState = { ...state };
123
             const newState = { ...state };
116
 
124
 
117
-            for (const key in action.participant) {
118
-                if (action.participant.hasOwnProperty(key)
125
+            for (const key in participant) {
126
+                if (participant.hasOwnProperty(key)
119
                         && PARTICIPANT_PROPS_TO_OMIT_WHEN_UPDATE.indexOf(key)
127
                         && PARTICIPANT_PROPS_TO_OMIT_WHEN_UPDATE.indexOf(key)
120
                             === -1) {
128
                             === -1) {
121
-                    newState[key] = action.participant[key];
129
+                    newState[key] = participant[key];
122
                 }
130
                 }
123
             }
131
             }
124
 
132
 
125
             if (!newState.avatar) {
133
             if (!newState.avatar) {
126
-                const { avatarId, avatarUrl, email } = newState;
127
-
128
-                newState.avatar = getAvatarURL(action.participant.id, {
129
-                    avatarId,
130
-                    avatarUrl,
131
-                    email
132
-                });
134
+                newState.avatar = getAvatarURL(newState);
133
             }
135
             }
134
 
136
 
135
             return newState;
137
             return newState;
136
         }
138
         }
137
         break;
139
         break;
140
+    }
138
 
141
 
139
     case PIN_PARTICIPANT:
142
     case PIN_PARTICIPANT:
140
         // Currently, only one pinned participant is allowed.
143
         // Currently, only one pinned participant is allowed.

Laden…
Annuleren
Opslaan