Adds avatarId and respect it with lowest priority.
This commit is contained in:
parent
3852b34397
commit
6f10156bf3
|
@ -37,6 +37,15 @@ export default {
|
||||||
this._setUserProp(id, "url", url);
|
this._setUserProp(id, "url", url);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the user's avatar id.
|
||||||
|
* @param id id of the user
|
||||||
|
* @param avatarId an id to be used for the avatar
|
||||||
|
*/
|
||||||
|
setUserAvatarID: function (id, avatarId) {
|
||||||
|
this._setUserProp(id, "avatarId", avatarId);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the URL of the image for the avatar of a particular user,
|
* Returns the URL of the image for the avatar of a particular user,
|
||||||
* identified by its id.
|
* identified by its id.
|
||||||
|
@ -55,11 +64,16 @@ export default {
|
||||||
let avatarId = null;
|
let avatarId = null;
|
||||||
const user = users[userId];
|
const user = users[userId];
|
||||||
|
|
||||||
|
// The priority is url, email and lowest is avatarId
|
||||||
if(user) {
|
if(user) {
|
||||||
if(user.url)
|
if(user.url)
|
||||||
return users[userId].url;
|
return user.url;
|
||||||
|
|
||||||
avatarId = users[userId].email;
|
if (user.email)
|
||||||
|
avatarId = user.email;
|
||||||
|
else {
|
||||||
|
avatarId = user.avatarId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the ID looks like an email, we'll use gravatar.
|
// If the ID looks like an email, we'll use gravatar.
|
||||||
|
|
Loading…
Reference in New Issue