Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
Avatar.js code cleanup
isymchych6df1fcef4004
diff --git a/modules/UI/avatar/Avatar.js b/modules/UI/avatar/Avatar.jsindex fca54102ac..31b489d439 100644--- a/modules/UI/avatar/Avatar.js+++ b/modules/UI/avatar/Avatar.js@@ -1,7 +1,8 @@-/* global Strophe, APP, MD5, config, interfaceConfig */-var users = {};+/* global MD5, config, interfaceConfig */-var Avatar = {+let users = {};++export default {/*** Sets the user's avatar in the settings menu(if local user), contact list@@ -9,55 +10,53 @@ var Avatar = {* @param id id of the user* @param email email or nickname to be used as a hash*/- setUserAvatar: function (id, email) {+ setUserAvatar: function (id, email) {if (email) {if (users[id] === email) {return;}users[id] = email;}- var avatarUrl = this.getAvatarUrl(id);},+/*** Returns the URL of the image for the avatar of a particular user,- + identified by its jid- * @param jid+ * identified by its id.+ * @param {string} userId user id*/- getAvatarUrl: function (jid) {+ getAvatarUrl: function (userId) {if (config.disableThirdPartyRequests) {return 'images/avatar2.png';- } else {- if (!jid) {- console.error("Get avatar - jid is undefined");- return null;- }- var id = users[jid];+ }- // If the ID looks like an email, we'll use gravatar.- // Otherwise, it's a random avatar, and we'll use the configured- // URL.- var random = !id || id.indexOf('@') < 0;+ if (!userId) {+ console.error("Get avatar - id is undefined");+ return null;+ }- if (!id) {- console.warn(- "No avatar stored yet for " + jid + " - using JID as ID");- id = jid;- }- id = MD5.hexdigest(id.trim().toLowerCase());+ let avatarId = users[userId];- // Default to using gravatar.- var urlPref = 'https://www.gravatar.com/avatar/';- var urlSuf = "?d=wavatar&size=100";+ // If the ID looks like an email, we'll use gravatar.+ // Otherwise, it's a random avatar, and we'll use the configured+ // URL.+ let random = !avatarId || avatarId.indexOf('@') < 0;- if (random && interfaceConfig.RANDOM_AVATAR_URL_PREFIX) {- urlPref = interfaceConfig.RANDOM_AVATAR_URL_PREFIX;- urlSuf = interfaceConfig.RANDOM_AVATAR_URL_SUFFIX;- }+ if (!avatarId) {+ console.warn(+ `No avatar stored yet for ${userId} - using ID as avatar ID`);+ avatarId = userId;+ }+ avatarId = MD5.hexdigest(avatarId.trim().toLowerCase());++ // Default to using gravatar.+ let urlPref = 'https://www.gravatar.com/avatar/';+ let urlSuf = "?d=wavatar&size=100";- return urlPref + id + urlSuf;+ if (random && interfaceConfig.RANDOM_AVATAR_URL_PREFIX) {+ urlPref = interfaceConfig.RANDOM_AVATAR_URL_PREFIX;+ urlSuf = interfaceConfig.RANDOM_AVATAR_URL_SUFFIX;}++ return urlPref + avatarId + urlSuf;}};---module.exports = Avatar;