From 6f10156bf320e693dea9f921b2c3db4e5815b6a6 Mon Sep 17 00:00:00 2001 From: damencho Date: Wed, 31 Aug 2016 11:37:11 -0500 Subject: [PATCH] Adds avatarId and respect it with lowest priority. --- modules/UI/avatar/Avatar.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/UI/avatar/Avatar.js b/modules/UI/avatar/Avatar.js index d068a8565..3d9fc3a31 100644 --- a/modules/UI/avatar/Avatar.js +++ b/modules/UI/avatar/Avatar.js @@ -37,6 +37,15 @@ export default { 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, * identified by its id. @@ -55,11 +64,16 @@ export default { let avatarId = null; const user = users[userId]; + // The priority is url, email and lowest is avatarId if(user) { 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.