Ver código fonte

Merge pull request #826 from jitsi/fix-random-avatar

Fixes random avatar
master
hristoterezov 8 anos atrás
pai
commit
19362d1904
4 arquivos alterados com 60 adições e 8 exclusões
  1. 8
    0
      conference.js
  2. 20
    6
      modules/UI/UI.js
  3. 16
    2
      modules/UI/avatar/Avatar.js
  4. 16
    0
      modules/settings/Settings.js

+ 8
- 0
conference.js Ver arquivo

48
     CONNECTION_QUALITY: "stats",
48
     CONNECTION_QUALITY: "stats",
49
     EMAIL: "email",
49
     EMAIL: "email",
50
     AVATAR_URL: "avatar-url",
50
     AVATAR_URL: "avatar-url",
51
+    AVATAR_ID: "avatar-id",
51
     ETHERPAD: "etherpad",
52
     ETHERPAD: "etherpad",
52
     SHARED_VIDEO: "shared-video",
53
     SHARED_VIDEO: "shared-video",
53
     CUSTOM_ROLE: "custom-role"
54
     CUSTOM_ROLE: "custom-role"
758
         let avatarUrl = APP.settings.getAvatarUrl();
759
         let avatarUrl = APP.settings.getAvatarUrl();
759
         avatarUrl && sendData(this.commands.defaults.AVATAR_URL,
760
         avatarUrl && sendData(this.commands.defaults.AVATAR_URL,
760
             avatarUrl);
761
             avatarUrl);
762
+        !email && sendData(
763
+             this.commands.defaults.AVATAR_ID, APP.settings.getAvatarId());
761
 
764
 
762
         let nick = APP.settings.getDisplayName();
765
         let nick = APP.settings.getDisplayName();
763
         if (config.useNicks && !nick) {
766
         if (config.useNicks && !nick) {
1257
             APP.UI.setUserAvatarUrl(from, data.value);
1260
             APP.UI.setUserAvatarUrl(from, data.value);
1258
         });
1261
         });
1259
 
1262
 
1263
+        room.addCommandListener(this.commands.defaults.AVATAR_ID,
1264
+            (data, from) => {
1265
+                APP.UI.setUserAvatarID(from, data.value);
1266
+            });
1267
+
1260
         APP.UI.addListener(UIEvents.NICKNAME_CHANGED, changeLocalDisplayName);
1268
         APP.UI.addListener(UIEvents.NICKNAME_CHANGED, changeLocalDisplayName);
1261
 
1269
 
1262
         APP.UI.addListener(UIEvents.START_MUTED_CHANGED,
1270
         APP.UI.addListener(UIEvents.START_MUTED_CHANGED,

+ 20
- 6
modules/UI/UI.js Ver arquivo

308
     }
308
     }
309
 
309
 
310
     // Make sure we configure our avatar id, before creating avatar for us
310
     // Make sure we configure our avatar id, before creating avatar for us
311
-    UI.setUserEmail(id, Settings.getEmail());
311
+    let email = Settings.getEmail();
312
+    if (email) {
313
+        UI.setUserEmail(id, email);
314
+    } else {
315
+        UI.setUserAvatarID(id, Settings.getAvatarId());
316
+    }
312
 
317
 
313
     Toolbar.checkAutoEnableDesktopSharing();
318
     Toolbar.checkAutoEnableDesktopSharing();
314
 
319
 
839
 /**
844
 /**
840
  * Updates the avatar for participant.
845
  * Updates the avatar for participant.
841
  * @param {string} id user id
846
  * @param {string} id user id
842
- * @param {stirng} avatarUrl the URL for the avatar
847
+ * @param {string} avatarUrl the URL for the avatar
843
  */
848
  */
844
 function changeAvatar(id, avatarUrl) {
849
 function changeAvatar(id, avatarUrl) {
845
     VideoLayout.changeUserAvatar(id, avatarUrl);
850
     VideoLayout.changeUserAvatar(id, avatarUrl);
852
 /**
857
 /**
853
  * Update user email.
858
  * Update user email.
854
  * @param {string} id user id
859
  * @param {string} id user id
855
- * @param {stirng} email user email
860
+ * @param {string} email user email
856
  */
861
  */
857
 UI.setUserEmail = function (id, email) {
862
 UI.setUserEmail = function (id, email) {
858
     // update avatar
863
     // update avatar
861
     changeAvatar(id, Avatar.getAvatarUrl(id));
866
     changeAvatar(id, Avatar.getAvatarUrl(id));
862
 };
867
 };
863
 
868
 
869
+/**
870
+ * Update user avtar id.
871
+ * @param {string} id user id
872
+ * @param {string} avatarId user's avatar id
873
+ */
874
+UI.setUserAvatarID = function (id, avatarId) {
875
+    // update avatar
876
+    Avatar.setUserAvatarID(id, avatarId);
877
+
878
+    changeAvatar(id, Avatar.getAvatarUrl(id));
879
+};
864
 
880
 
865
 /**
881
 /**
866
  * Update user avatar URL.
882
  * Update user avatar URL.
867
  * @param {string} id user id
883
  * @param {string} id user id
868
- * @param {stirng} url user avatar url
884
+ * @param {string} url user avatar url
869
  */
885
  */
870
 UI.setUserAvatarUrl = function (id, url) {
886
 UI.setUserAvatarUrl = function (id, url) {
871
     // update avatar
887
     // update avatar
1440
     Toolbar.markAudioIconAsDisabled(false);
1456
     Toolbar.markAudioIconAsDisabled(false);
1441
 };
1457
 };
1442
 
1458
 
1443
-let bottomToolbarEnabled = null;
1444
-
1445
 UI.showRingOverLay = function () {
1459
 UI.showRingOverLay = function () {
1446
     RingOverlay.show(APP.tokenData.callee);
1460
     RingOverlay.show(APP.tokenData.callee);
1447
     FilmStrip.toggleFilmStrip(false);
1461
     FilmStrip.toggleFilmStrip(false);

+ 16
- 2
modules/UI/avatar/Avatar.js Ver arquivo

37
         this._setUserProp(id, "url", url);
37
         this._setUserProp(id, "url", url);
38
     },
38
     },
39
 
39
 
40
+    /**
41
+     * Sets the user's avatar id.
42
+     * @param id id of the user
43
+     * @param avatarId an id to be used for the avatar
44
+     */
45
+    setUserAvatarID: function (id, avatarId) {
46
+        this._setUserProp(id, "avatarId", avatarId);
47
+    },
48
+
40
     /**
49
     /**
41
      * Returns the URL of the image for the avatar of a particular user,
50
      * Returns the URL of the image for the avatar of a particular user,
42
      * identified by its id.
51
      * identified by its id.
55
         let avatarId = null;
64
         let avatarId = null;
56
         const user = users[userId];
65
         const user = users[userId];
57
 
66
 
67
+        // The priority is url, email and lowest is avatarId
58
         if(user) {
68
         if(user) {
59
             if(user.url)
69
             if(user.url)
60
-                return users[userId].url;
70
+                return user.url;
61
 
71
 
62
-            avatarId = users[userId].email;
72
+            if (user.email)
73
+                avatarId = user.email;
74
+            else {
75
+                avatarId = user.avatarId;
76
+            }
63
         }
77
         }
64
 
78
 
65
         // If the ID looks like an email, we'll use gravatar.
79
         // If the ID looks like an email, we'll use gravatar.

+ 16
- 0
modules/settings/Settings.js Ver arquivo

3
 import UIUtil from '../UI/util/UIUtil';
3
 import UIUtil from '../UI/util/UIUtil';
4
 
4
 
5
 let email = '';
5
 let email = '';
6
+let avatarId = '';
6
 let displayName = '';
7
 let displayName = '';
7
 let language = null;
8
 let language = null;
8
 let cameraDeviceId = '';
9
 let cameraDeviceId = '';
35
     }
36
     }
36
 
37
 
37
     email = UIUtil.unescapeHtml(window.localStorage.email || '');
38
     email = UIUtil.unescapeHtml(window.localStorage.email || '');
39
+    avatarId = UIUtil.unescapeHtml(window.localStorage.avatarId || '');
40
+    if (!avatarId) {
41
+        // if there is no avatar id, we generate a unique one and use it forever
42
+        avatarId = generateUniqueId();
43
+        window.localStorage.avatarId = avatarId;
44
+    }
45
+
38
     localFlipX = JSON.parse(window.localStorage.localFlipX || true);
46
     localFlipX = JSON.parse(window.localStorage.localFlipX || true);
39
     displayName = UIUtil.unescapeHtml(window.localStorage.displayname || '');
47
     displayName = UIUtil.unescapeHtml(window.localStorage.displayname || '');
40
     language = window.localStorage.language;
48
     language = window.localStorage.language;
105
         return email;
113
         return email;
106
     },
114
     },
107
 
115
 
116
+    /**
117
+     * Returns avatar id of the local user.
118
+     * @returns {string} avatar id
119
+     */
120
+    getAvatarId: function () {
121
+        return avatarId;
122
+    },
123
+
108
     /**
124
     /**
109
      * Sets new avatarUrl for local user and saves it to the local storage.
125
      * Sets new avatarUrl for local user and saves it to the local storage.
110
      * @param {string} newAvatarUrl new avatarUrl for the local user
126
      * @param {string} newAvatarUrl new avatarUrl for the local user

Carregando…
Cancelar
Salvar