瀏覽代碼

Adds avatarId and respect it with lowest priority.

master
damencho 9 年之前
父節點
當前提交
6f10156bf3
共有 1 個檔案被更改,包括 16 行新增2 行删除
  1. 16
    2
      modules/UI/avatar/Avatar.js

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

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.

Loading…
取消
儲存