浏览代码

fix(avatar): Avatar properties not updated before local user join

Replaces changeAvatarID, changeAvatarURL and changeEmail with
participantUpdated action.
participantUpdated can be fired for local user without id. This
fixes the problem with updating the local user before the user
join the conference which results in fix for failing to execute
commands for avatarID, avatarURL and email right after the iframe
api creates the iframe with Jitsi Meet.
j8
hristoterezov 8 年前
父节点
当前提交
4ab4aa04da

+ 36
- 11
conference.js 查看文件

32
     isFatalJitsiConnectionError
32
     isFatalJitsiConnectionError
33
 } from './react/features/base/lib-jitsi-meet';
33
 } from './react/features/base/lib-jitsi-meet';
34
 import {
34
 import {
35
-    changeParticipantAvatarID,
36
-    changeParticipantAvatarURL,
37
-    changeParticipantEmail,
38
     participantJoined,
35
     participantJoined,
39
     participantLeft,
36
     participantLeft,
40
-    participantRoleChanged
37
+    participantRoleChanged,
38
+    participantUpdated
41
 } from './react/features/base/participants';
39
 } from './react/features/base/participants';
42
 import {
40
 import {
43
     mediaPermissionPromptVisibilityChanged,
41
     mediaPermissionPromptVisibilityChanged,
161
  * @param {string} value new value
159
  * @param {string} value new value
162
  */
160
  */
163
 function sendData (command, value) {
161
 function sendData (command, value) {
162
+    if(!room) {
163
+        return;
164
+    }
165
+
164
     room.removeCommand(command);
166
     room.removeCommand(command);
165
     room.sendCommand(command, {value: value});
167
     room.sendCommand(command, {value: value});
166
 }
168
 }
1469
 
1471
 
1470
         APP.UI.addListener(UIEvents.EMAIL_CHANGED, this.changeLocalEmail);
1472
         APP.UI.addListener(UIEvents.EMAIL_CHANGED, this.changeLocalEmail);
1471
         room.addCommandListener(this.commands.defaults.EMAIL, (data, from) => {
1473
         room.addCommandListener(this.commands.defaults.EMAIL, (data, from) => {
1472
-            APP.store.dispatch(changeParticipantEmail(from, data.value));
1474
+            APP.store.dispatch(participantUpdated({
1475
+                id: from,
1476
+                email: data.value
1477
+            }));
1473
             APP.UI.setUserEmail(from, data.value);
1478
             APP.UI.setUserEmail(from, data.value);
1474
         });
1479
         });
1475
 
1480
 
1477
             this.commands.defaults.AVATAR_URL,
1482
             this.commands.defaults.AVATAR_URL,
1478
             (data, from) => {
1483
             (data, from) => {
1479
                 APP.store.dispatch(
1484
                 APP.store.dispatch(
1480
-                    changeParticipantAvatarURL(from, data.value));
1485
+                    participantUpdated({
1486
+                        id: from,
1487
+                        avatarURL: data.value
1488
+                    }));
1481
                 APP.UI.setUserAvatarUrl(from, data.value);
1489
                 APP.UI.setUserAvatarUrl(from, data.value);
1482
         });
1490
         });
1483
 
1491
 
1484
         room.addCommandListener(this.commands.defaults.AVATAR_ID,
1492
         room.addCommandListener(this.commands.defaults.AVATAR_ID,
1485
             (data, from) => {
1493
             (data, from) => {
1486
                 APP.store.dispatch(
1494
                 APP.store.dispatch(
1487
-                    changeParticipantAvatarID(from, data.value));
1495
+                    participantUpdated({
1496
+                        id: from,
1497
+                        avatarID: data.value
1498
+                    }));
1488
                 APP.UI.setUserAvatarID(from, data.value);
1499
                 APP.UI.setUserAvatarID(from, data.value);
1489
             });
1500
             });
1490
 
1501
 
1896
         if (email === APP.settings.getEmail()) {
1907
         if (email === APP.settings.getEmail()) {
1897
             return;
1908
             return;
1898
         }
1909
         }
1899
-        APP.store.dispatch(changeParticipantEmail(room.myUserId(), email));
1910
+
1911
+        const localId = room ? room.myUserId() : undefined;
1912
+
1913
+        APP.store.dispatch(participantUpdated({
1914
+            id: localId,
1915
+            local: true,
1916
+            email
1917
+        }));
1900
 
1918
 
1901
         APP.settings.setEmail(email);
1919
         APP.settings.setEmail(email);
1902
-        APP.UI.setUserEmail(room.myUserId(), email);
1920
+        APP.UI.setUserEmail(localId, email);
1903
         sendData(commands.EMAIL, email);
1921
         sendData(commands.EMAIL, email);
1904
     },
1922
     },
1905
 
1923
 
1913
         if (url === APP.settings.getAvatarUrl()) {
1931
         if (url === APP.settings.getAvatarUrl()) {
1914
             return;
1932
             return;
1915
         }
1933
         }
1916
-        APP.store.dispatch(changeParticipantAvatarURL(room.myUserId(), url));
1934
+
1935
+        const localId = room ? room.myUserId() : undefined;
1936
+
1937
+        APP.store.dispatch(participantUpdated({
1938
+            id: localId,
1939
+            local: true,
1940
+            avatarURL: url
1941
+        }));
1917
 
1942
 
1918
         APP.settings.setAvatarUrl(url);
1943
         APP.settings.setAvatarUrl(url);
1919
-        APP.UI.setUserAvatarUrl(room.myUserId(), url);
1944
+        APP.UI.setUserAvatarUrl(localId, url);
1920
         sendData(commands.AVATAR_URL, url);
1945
         sendData(commands.AVATAR_URL, url);
1921
     },
1946
     },
1922
 
1947
 

+ 3
- 0
modules/UI/UI.js 查看文件

762
     Avatar.setUserEmail(id, email);
762
     Avatar.setUserEmail(id, email);
763
 
763
 
764
     changeAvatar(id, Avatar.getAvatarUrl(id));
764
     changeAvatar(id, Avatar.getAvatarUrl(id));
765
+    if (APP.conference.isLocalId(id)) {
766
+        Profile.changeEmail(email);
767
+    }
765
 };
768
 };
766
 
769
 
767
 /**
770
 /**

+ 2
- 2
modules/UI/avatar/Avatar.js 查看文件

30
 export default {
30
 export default {
31
     /**
31
     /**
32
      * Sets prop in users object.
32
      * Sets prop in users object.
33
-     * @param id {string} user id
33
+     * @param id {string} user id or undefined for the local user.
34
      * @param prop {string} name of the prop
34
      * @param prop {string} name of the prop
35
      * @param val {string} value to be set
35
      * @param val {string} value to be set
36
      */
36
      */
38
         // FIXME: Fixes the issue with not be able to return avatar for the
38
         // FIXME: Fixes the issue with not be able to return avatar for the
39
         // local user when the conference has been left. Maybe there is beter
39
         // local user when the conference has been left. Maybe there is beter
40
         // way to solve it.
40
         // way to solve it.
41
-        if(APP.conference.isLocalId(id)) {
41
+        if(!id || APP.conference.isLocalId(id)) {
42
             id = "local";
42
             id = "local";
43
         }
43
         }
44
         if(!val || (users[id] && users[id][prop] === val))
44
         if(!val || (users[id] && users[id][prop] === val))

+ 10
- 2
modules/UI/side_pannels/profile/Profile.js 查看文件

15
         </div>
15
         </div>
16
         <div class="sideToolbarBlock">
16
         <div class="sideToolbarBlock">
17
             <label data-i18n="profile.setEmailLabel"></label>
17
             <label data-i18n="profile.setEmailLabel"></label>
18
-            <input id="setEmail" type="text" class="input-control" 
18
+            <input id="setEmail" type="text" class="input-control"
19
                 data-i18n="[placeholder]profile.setEmailInput">
19
                 data-i18n="[placeholder]profile.setEmailInput">
20
         </div>
20
         </div>
21
-        <div id="profile_auth_container" 
21
+        <div id="profile_auth_container"
22
              class="sideToolbarBlock auth_container">
22
              class="sideToolbarBlock auth_container">
23
             <p data-i18n="toolbar.authenticate"></p>
23
             <p data-i18n="toolbar.authenticate"></p>
24
             <ul>
24
             <ul>
122
         $('#avatar').attr('src', avatarUrl);
122
         $('#avatar').attr('src', avatarUrl);
123
     },
123
     },
124
 
124
 
125
+    /**
126
+     * Change the value of the field for the user email.
127
+     * @param {string} email the new value that will be displayed in the field.
128
+     */
129
+    changeEmail (email) {
130
+        $('#setEmail').val(email);
131
+    },
132
+
125
     /**
133
     /**
126
      * Shows or hides authentication related buttons
134
      * Shows or hides authentication related buttons
127
      * @param {boolean} show <tt>true</tt> to show or <tt>false</tt> to hide
135
      * @param {boolean} show <tt>true</tt> to show or <tt>false</tt> to hide

+ 14
- 7
react/features/base/conference/actions.js 查看文件

1
 import { JitsiConferenceEvents } from '../lib-jitsi-meet';
1
 import { JitsiConferenceEvents } from '../lib-jitsi-meet';
2
 import {
2
 import {
3
-    changeParticipantAvatarID,
4
-    changeParticipantAvatarURL,
5
-    changeParticipantEmail,
6
     dominantSpeakerChanged,
3
     dominantSpeakerChanged,
7
     getLocalParticipant,
4
     getLocalParticipant,
8
     participantJoined,
5
     participantJoined,
9
     participantLeft,
6
     participantLeft,
10
-    participantRoleChanged
7
+    participantRoleChanged,
8
+    participantUpdated
11
 } from '../participants';
9
 } from '../participants';
12
 import { trackAdded, trackRemoved } from '../tracks';
10
 import { trackAdded, trackRemoved } from '../tracks';
13
 
11
 
78
 
76
 
79
     conference.addCommandListener(
77
     conference.addCommandListener(
80
             AVATAR_ID_COMMAND,
78
             AVATAR_ID_COMMAND,
81
-            (data, id) => dispatch(changeParticipantAvatarID(id, data.value)));
79
+            (data, id) => dispatch(participantUpdated({
80
+                id,
81
+                avatarID: data.value
82
+            })));
82
     conference.addCommandListener(
83
     conference.addCommandListener(
83
             AVATAR_URL_COMMAND,
84
             AVATAR_URL_COMMAND,
84
-            (data, id) => dispatch(changeParticipantAvatarURL(id, data.value)));
85
+            (data, id) => dispatch(participantUpdated({
86
+                id,
87
+                avatarURL: data.value
88
+            })));
85
     conference.addCommandListener(
89
     conference.addCommandListener(
86
             EMAIL_COMMAND,
90
             EMAIL_COMMAND,
87
-            (data, id) => dispatch(changeParticipantEmail(id, data.value)));
91
+            (data, id) => dispatch(participantUpdated({
92
+                id,
93
+                email: data.value
94
+            })));
88
 }
95
 }
89
 
96
 
90
 /**
97
 /**

+ 20
- 73
react/features/base/participants/actions.js 查看文件

8
 } from './actionTypes';
8
 } from './actionTypes';
9
 import { getLocalParticipant } from './functions';
9
 import { getLocalParticipant } from './functions';
10
 
10
 
11
-/**
12
- * Action to update a participant's avatar ID.
13
- *
14
- * @param {string} id - Participant's ID.
15
- * @param {string} avatarID - Participant's avatar ID.
16
- * @returns {{
17
- *     type: PARTICIPANT_UPDATED,
18
- *     participant: {
19
- *         id: string,
20
- *         avatarID: string,
21
- *     }
22
- * }}
23
- */
24
-export function changeParticipantAvatarID(id, avatarID) {
25
-    return {
26
-        type: PARTICIPANT_UPDATED,
27
-        participant: {
28
-            id,
29
-            avatarID
30
-        }
31
-    };
32
-}
33
-
34
-/**
35
- * Action to update a participant's avatar URL.
36
- *
37
- * @param {string} id - Participant's ID.
38
- * @param {string} avatarURL - Participant's avatar URL.
39
- * @returns {{
40
- *     type: PARTICIPANT_UPDATED,
41
- *     participant: {
42
- *         id: string,
43
- *         avatarURL: string,
44
- *     }
45
- * }}
46
- */
47
-export function changeParticipantAvatarURL(id, avatarURL) {
48
-    return {
49
-        type: PARTICIPANT_UPDATED,
50
-        participant: {
51
-            id,
52
-            avatarURL
53
-        }
54
-    };
55
-}
56
-
57
-/**
58
- * Action to update a participant's email.
59
- *
60
- * @param {string} id - Participant's ID.
61
- * @param {string} email - Participant's email.
62
- * @returns {{
63
- *     type: PARTICIPANT_UPDATED,
64
- *     participant: {
65
- *         id: string,
66
- *         email: string
67
- *     }
68
- * }}
69
- */
70
-export function changeParticipantEmail(id, email) {
71
-    return {
72
-        type: PARTICIPANT_UPDATED,
73
-        participant: {
74
-            id,
75
-            email
76
-        }
77
-    };
78
-}
79
-
80
 /**
11
 /**
81
  * Create an action for when dominant speaker changes.
12
  * Create an action for when dominant speaker changes.
82
  *
13
  *
203
  * }}
134
  * }}
204
  */
135
  */
205
 export function participantRoleChanged(id, role) {
136
 export function participantRoleChanged(id, role) {
137
+    return participantUpdated({
138
+        id,
139
+        role
140
+    });
141
+}
142
+
143
+/**
144
+ * Action to signal that some of participant properties has been changed.
145
+ *
146
+ * @param {Participant} participant={} - Information about participant. To
147
+ * identify the participant the object should contain either property id with
148
+ * value the id of the participant or property local with value true (if the
149
+ * local participant hasn't joined the conference yet).
150
+ * @returns {{
151
+ *     type: PARTICIPANT_UPDATED,
152
+ *     participant: Participant
153
+ * }}
154
+ */
155
+export function participantUpdated(participant = {}) {
206
     return {
156
     return {
207
         type: PARTICIPANT_UPDATED,
157
         type: PARTICIPANT_UPDATED,
208
-        participant: {
209
-            id,
210
-            role
211
-        }
158
+        participant
212
     };
159
     };
213
 }
160
 }
214
 
161
 

+ 6
- 1
react/features/base/participants/reducer.js 查看文件

112
 
112
 
113
     case PARTICIPANT_UPDATED: {
113
     case PARTICIPANT_UPDATED: {
114
         const participant = action.participant; // eslint-disable-line no-shadow
114
         const participant = action.participant; // eslint-disable-line no-shadow
115
-        const { id } = participant;
115
+        const { local } = participant;
116
+        let { id } = participant;
117
+
118
+        if (!id && local) {
119
+            id = LOCAL_PARTICIPANT_DEFAULT_ID;
120
+        }
116
 
121
 
117
         if (state.id === id) {
122
         if (state.id === id) {
118
             const newState = { ...state };
123
             const newState = { ...state };

正在加载...
取消
保存