Browse Source

Adds avatarId and respect it with lowest priority.

master
damencho 9 years ago
parent
commit
6f10156bf3
1 changed files with 16 additions and 2 deletions
  1. 16
    2
      modules/UI/avatar/Avatar.js

+ 16
- 2
modules/UI/avatar/Avatar.js View File

@@ -37,6 +37,15 @@ export default {
37 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 50
      * Returns the URL of the image for the avatar of a particular user,
42 51
      * identified by its id.
@@ -55,11 +64,16 @@ export default {
55 64
         let avatarId = null;
56 65
         const user = users[userId];
57 66
 
67
+        // The priority is url, email and lowest is avatarId
58 68
         if(user) {
59 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 79
         // If the ID looks like an email, we'll use gravatar.

Loading…
Cancel
Save