From 3852b343976acd3e8a2a4f50e6d10a07b0fe7ee7 Mon Sep 17 00:00:00 2001 From: damencho Date: Wed, 31 Aug 2016 11:24:51 -0500 Subject: [PATCH 1/4] Adds avatarId to Settings. --- modules/settings/Settings.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/settings/Settings.js b/modules/settings/Settings.js index ebd7ab52a..1f629bb48 100644 --- a/modules/settings/Settings.js +++ b/modules/settings/Settings.js @@ -3,6 +3,7 @@ import UIUtil from '../UI/util/UIUtil'; let email = ''; +let avatarId = ''; let displayName = ''; let language = null; let cameraDeviceId = ''; @@ -35,6 +36,13 @@ if (supportsLocalStorage()) { } email = UIUtil.unescapeHtml(window.localStorage.email || ''); + avatarId = UIUtil.unescapeHtml(window.localStorage.avatarId || ''); + if (!avatarId) { + // if there is no avatar id, we generate a unique one and use it forever + avatarId = generateUniqueId(); + window.localStorage.avatarId = avatarId; + } + localFlipX = JSON.parse(window.localStorage.localFlipX || true); displayName = UIUtil.unescapeHtml(window.localStorage.displayname || ''); language = window.localStorage.language; @@ -105,6 +113,14 @@ export default { return email; }, + /** + * Returns avatar id of the local user. + * @returns {string} avatar id + */ + getAvatarId: function () { + return avatarId; + }, + /** * Sets new avatarUrl for local user and saves it to the local storage. * @param {string} newAvatarUrl new avatarUrl for the local user From 6f10156bf320e693dea9f921b2c3db4e5815b6a6 Mon Sep 17 00:00:00 2001 From: damencho Date: Wed, 31 Aug 2016 11:37:11 -0500 Subject: [PATCH 2/4] 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. From 3138748f570c94a205dd3f5f5f428f6f72cce89d Mon Sep 17 00:00:00 2001 From: damencho Date: Wed, 31 Aug 2016 11:40:06 -0500 Subject: [PATCH 3/4] Uses avatarId from settings. Removes unused variable bottomToolbarEnabled. --- modules/UI/UI.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/modules/UI/UI.js b/modules/UI/UI.js index fc0565d9a..2eeb5b449 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -308,7 +308,12 @@ UI.initConference = function () { } // Make sure we configure our avatar id, before creating avatar for us - UI.setUserEmail(id, Settings.getEmail()); + let email = Settings.getEmail(); + if (email) { + UI.setUserEmail(id, email); + } else { + UI.setUserAvatarID(id, Settings.getAvatarId()); + } Toolbar.checkAutoEnableDesktopSharing(); @@ -839,7 +844,7 @@ UI.dockToolbar = function (isDock) { /** * Updates the avatar for participant. * @param {string} id user id - * @param {stirng} avatarUrl the URL for the avatar + * @param {string} avatarUrl the URL for the avatar */ function changeAvatar(id, avatarUrl) { VideoLayout.changeUserAvatar(id, avatarUrl); @@ -852,7 +857,7 @@ function changeAvatar(id, avatarUrl) { /** * Update user email. * @param {string} id user id - * @param {stirng} email user email + * @param {string} email user email */ UI.setUserEmail = function (id, email) { // update avatar @@ -861,11 +866,22 @@ UI.setUserEmail = function (id, email) { changeAvatar(id, Avatar.getAvatarUrl(id)); }; +/** + * Update user avtar id. + * @param {string} id user id + * @param {string} avatarId user's avatar id + */ +UI.setUserAvatarID = function (id, avatarId) { + // update avatar + Avatar.setUserAvatarID(id, avatarId); + + changeAvatar(id, Avatar.getAvatarUrl(id)); +}; /** * Update user avatar URL. * @param {string} id user id - * @param {stirng} url user avatar url + * @param {string} url user avatar url */ UI.setUserAvatarUrl = function (id, url) { // update avatar @@ -1440,8 +1456,6 @@ UI.enableMicrophoneButton = function () { Toolbar.markAudioIconAsDisabled(false); }; -let bottomToolbarEnabled = null; - UI.showRingOverLay = function () { RingOverlay.show(APP.tokenData.callee); FilmStrip.toggleFilmStrip(false); From 8e6d7d39600f50cf92086f6d00c36acd5af381ec Mon Sep 17 00:00:00 2001 From: damencho Date: Wed, 31 Aug 2016 11:41:17 -0500 Subject: [PATCH 4/4] Sends and dispatches avatarId command. --- conference.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/conference.js b/conference.js index 0e3a50d16..0247eec27 100644 --- a/conference.js +++ b/conference.js @@ -48,6 +48,7 @@ const commands = { CONNECTION_QUALITY: "stats", EMAIL: "email", AVATAR_URL: "avatar-url", + AVATAR_ID: "avatar-id", ETHERPAD: "etherpad", SHARED_VIDEO: "shared-video", CUSTOM_ROLE: "custom-role" @@ -758,6 +759,8 @@ export default { let avatarUrl = APP.settings.getAvatarUrl(); avatarUrl && sendData(this.commands.defaults.AVATAR_URL, avatarUrl); + !email && sendData( + this.commands.defaults.AVATAR_ID, APP.settings.getAvatarId()); let nick = APP.settings.getDisplayName(); if (config.useNicks && !nick) { @@ -1257,6 +1260,11 @@ export default { APP.UI.setUserAvatarUrl(from, data.value); }); + room.addCommandListener(this.commands.defaults.AVATAR_ID, + (data, from) => { + APP.UI.setUserAvatarID(from, data.value); + }); + APP.UI.addListener(UIEvents.NICKNAME_CHANGED, changeLocalDisplayName); APP.UI.addListener(UIEvents.START_MUTED_CHANGED,