From 4ab4aa04da4844f0cf69f6d191bde075a5337504 Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Thu, 23 Mar 2017 13:01:33 -0500 Subject: [PATCH] fix(avatar): Avatar properties not updated before local user join Replaces changeAvatarID, changeAvatarURL and changeEmail with participantUpdated action. participantUpdated can be fired for local user without id. This fixes the problem with updating the local user before the user join the conference which results in fix for failing to execute commands for avatarID, avatarURL and email right after the iframe api creates the iframe with Jitsi Meet. --- conference.js | 47 ++++++++--- modules/UI/UI.js | 3 + modules/UI/avatar/Avatar.js | 4 +- modules/UI/side_pannels/profile/Profile.js | 12 ++- react/features/base/conference/actions.js | 21 +++-- react/features/base/participants/actions.js | 93 +++++---------------- react/features/base/participants/reducer.js | 7 +- 7 files changed, 91 insertions(+), 96 deletions(-) diff --git a/conference.js b/conference.js index 8dc5c2afc..12470b209 100644 --- a/conference.js +++ b/conference.js @@ -32,12 +32,10 @@ import { isFatalJitsiConnectionError } from './react/features/base/lib-jitsi-meet'; import { - changeParticipantAvatarID, - changeParticipantAvatarURL, - changeParticipantEmail, participantJoined, participantLeft, - participantRoleChanged + participantRoleChanged, + participantUpdated } from './react/features/base/participants'; import { mediaPermissionPromptVisibilityChanged, @@ -161,6 +159,10 @@ function createInitialLocalTracksAndConnect(roomName) { * @param {string} value new value */ function sendData (command, value) { + if(!room) { + return; + } + room.removeCommand(command); room.sendCommand(command, {value: value}); } @@ -1469,7 +1471,10 @@ export default { APP.UI.addListener(UIEvents.EMAIL_CHANGED, this.changeLocalEmail); room.addCommandListener(this.commands.defaults.EMAIL, (data, from) => { - APP.store.dispatch(changeParticipantEmail(from, data.value)); + APP.store.dispatch(participantUpdated({ + id: from, + email: data.value + })); APP.UI.setUserEmail(from, data.value); }); @@ -1477,14 +1482,20 @@ export default { this.commands.defaults.AVATAR_URL, (data, from) => { APP.store.dispatch( - changeParticipantAvatarURL(from, data.value)); + participantUpdated({ + id: from, + avatarURL: data.value + })); APP.UI.setUserAvatarUrl(from, data.value); }); room.addCommandListener(this.commands.defaults.AVATAR_ID, (data, from) => { APP.store.dispatch( - changeParticipantAvatarID(from, data.value)); + participantUpdated({ + id: from, + avatarID: data.value + })); APP.UI.setUserAvatarID(from, data.value); }); @@ -1896,10 +1907,17 @@ export default { if (email === APP.settings.getEmail()) { return; } - APP.store.dispatch(changeParticipantEmail(room.myUserId(), email)); + + const localId = room ? room.myUserId() : undefined; + + APP.store.dispatch(participantUpdated({ + id: localId, + local: true, + email + })); APP.settings.setEmail(email); - APP.UI.setUserEmail(room.myUserId(), email); + APP.UI.setUserEmail(localId, email); sendData(commands.EMAIL, email); }, @@ -1913,10 +1931,17 @@ export default { if (url === APP.settings.getAvatarUrl()) { return; } - APP.store.dispatch(changeParticipantAvatarURL(room.myUserId(), url)); + + const localId = room ? room.myUserId() : undefined; + + APP.store.dispatch(participantUpdated({ + id: localId, + local: true, + avatarURL: url + })); APP.settings.setAvatarUrl(url); - APP.UI.setUserAvatarUrl(room.myUserId(), url); + APP.UI.setUserAvatarUrl(localId, url); sendData(commands.AVATAR_URL, url); }, diff --git a/modules/UI/UI.js b/modules/UI/UI.js index 75a05522d..56bd4c6c9 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -762,6 +762,9 @@ UI.setUserEmail = function (id, email) { Avatar.setUserEmail(id, email); changeAvatar(id, Avatar.getAvatarUrl(id)); + if (APP.conference.isLocalId(id)) { + Profile.changeEmail(email); + } }; /** diff --git a/modules/UI/avatar/Avatar.js b/modules/UI/avatar/Avatar.js index e29619dee..198dac073 100644 --- a/modules/UI/avatar/Avatar.js +++ b/modules/UI/avatar/Avatar.js @@ -30,7 +30,7 @@ let users = {}; export default { /** * Sets prop in users object. - * @param id {string} user id + * @param id {string} user id or undefined for the local user. * @param prop {string} name of the prop * @param val {string} value to be set */ @@ -38,7 +38,7 @@ export default { // FIXME: Fixes the issue with not be able to return avatar for the // local user when the conference has been left. Maybe there is beter // way to solve it. - if(APP.conference.isLocalId(id)) { + if(!id || APP.conference.isLocalId(id)) { id = "local"; } if(!val || (users[id] && users[id][prop] === val)) diff --git a/modules/UI/side_pannels/profile/Profile.js b/modules/UI/side_pannels/profile/Profile.js index 45c1a8caa..c08d2b9a9 100644 --- a/modules/UI/side_pannels/profile/Profile.js +++ b/modules/UI/side_pannels/profile/Profile.js @@ -15,10 +15,10 @@ const htmlStr = `
-
-