Merge pull request #826 from jitsi/fix-random-avatar
Fixes random avatar
This commit is contained in:
commit
19362d1904
@ -48,6 +48,7 @@ const commands = {
|
|||||||
CONNECTION_QUALITY: "stats",
|
CONNECTION_QUALITY: "stats",
|
||||||
EMAIL: "email",
|
EMAIL: "email",
|
||||||
AVATAR_URL: "avatar-url",
|
AVATAR_URL: "avatar-url",
|
||||||
|
AVATAR_ID: "avatar-id",
|
||||||
ETHERPAD: "etherpad",
|
ETHERPAD: "etherpad",
|
||||||
SHARED_VIDEO: "shared-video",
|
SHARED_VIDEO: "shared-video",
|
||||||
CUSTOM_ROLE: "custom-role"
|
CUSTOM_ROLE: "custom-role"
|
||||||
@ -758,6 +759,8 @@ export default {
|
|||||||
let avatarUrl = APP.settings.getAvatarUrl();
|
let avatarUrl = APP.settings.getAvatarUrl();
|
||||||
avatarUrl && sendData(this.commands.defaults.AVATAR_URL,
|
avatarUrl && sendData(this.commands.defaults.AVATAR_URL,
|
||||||
avatarUrl);
|
avatarUrl);
|
||||||
|
!email && sendData(
|
||||||
|
this.commands.defaults.AVATAR_ID, APP.settings.getAvatarId());
|
||||||
|
|
||||||
let nick = APP.settings.getDisplayName();
|
let nick = APP.settings.getDisplayName();
|
||||||
if (config.useNicks && !nick) {
|
if (config.useNicks && !nick) {
|
||||||
@ -1257,6 +1260,11 @@ export default {
|
|||||||
APP.UI.setUserAvatarUrl(from, data.value);
|
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.NICKNAME_CHANGED, changeLocalDisplayName);
|
||||||
|
|
||||||
APP.UI.addListener(UIEvents.START_MUTED_CHANGED,
|
APP.UI.addListener(UIEvents.START_MUTED_CHANGED,
|
||||||
|
|||||||
@ -308,7 +308,12 @@ UI.initConference = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we configure our avatar id, before creating avatar for us
|
// 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();
|
Toolbar.checkAutoEnableDesktopSharing();
|
||||||
|
|
||||||
@ -839,7 +844,7 @@ UI.dockToolbar = function (isDock) {
|
|||||||
/**
|
/**
|
||||||
* Updates the avatar for participant.
|
* Updates the avatar for participant.
|
||||||
* @param {string} id user id
|
* @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) {
|
function changeAvatar(id, avatarUrl) {
|
||||||
VideoLayout.changeUserAvatar(id, avatarUrl);
|
VideoLayout.changeUserAvatar(id, avatarUrl);
|
||||||
@ -852,7 +857,7 @@ function changeAvatar(id, avatarUrl) {
|
|||||||
/**
|
/**
|
||||||
* Update user email.
|
* Update user email.
|
||||||
* @param {string} id user id
|
* @param {string} id user id
|
||||||
* @param {stirng} email user email
|
* @param {string} email user email
|
||||||
*/
|
*/
|
||||||
UI.setUserEmail = function (id, email) {
|
UI.setUserEmail = function (id, email) {
|
||||||
// update avatar
|
// update avatar
|
||||||
@ -861,11 +866,22 @@ UI.setUserEmail = function (id, email) {
|
|||||||
changeAvatar(id, Avatar.getAvatarUrl(id));
|
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.
|
* Update user avatar URL.
|
||||||
* @param {string} id user id
|
* @param {string} id user id
|
||||||
* @param {stirng} url user avatar url
|
* @param {string} url user avatar url
|
||||||
*/
|
*/
|
||||||
UI.setUserAvatarUrl = function (id, url) {
|
UI.setUserAvatarUrl = function (id, url) {
|
||||||
// update avatar
|
// update avatar
|
||||||
@ -1440,8 +1456,6 @@ UI.enableMicrophoneButton = function () {
|
|||||||
Toolbar.markAudioIconAsDisabled(false);
|
Toolbar.markAudioIconAsDisabled(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
let bottomToolbarEnabled = null;
|
|
||||||
|
|
||||||
UI.showRingOverLay = function () {
|
UI.showRingOverLay = function () {
|
||||||
RingOverlay.show(APP.tokenData.callee);
|
RingOverlay.show(APP.tokenData.callee);
|
||||||
FilmStrip.toggleFilmStrip(false);
|
FilmStrip.toggleFilmStrip(false);
|
||||||
|
|||||||
@ -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.
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
import UIUtil from '../UI/util/UIUtil';
|
import UIUtil from '../UI/util/UIUtil';
|
||||||
|
|
||||||
let email = '';
|
let email = '';
|
||||||
|
let avatarId = '';
|
||||||
let displayName = '';
|
let displayName = '';
|
||||||
let language = null;
|
let language = null;
|
||||||
let cameraDeviceId = '';
|
let cameraDeviceId = '';
|
||||||
@ -35,6 +36,13 @@ if (supportsLocalStorage()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
email = UIUtil.unescapeHtml(window.localStorage.email || '');
|
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);
|
localFlipX = JSON.parse(window.localStorage.localFlipX || true);
|
||||||
displayName = UIUtil.unescapeHtml(window.localStorage.displayname || '');
|
displayName = UIUtil.unescapeHtml(window.localStorage.displayname || '');
|
||||||
language = window.localStorage.language;
|
language = window.localStorage.language;
|
||||||
@ -105,6 +113,14 @@ export default {
|
|||||||
return email;
|
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.
|
* Sets new avatarUrl for local user and saves it to the local storage.
|
||||||
* @param {string} newAvatarUrl new avatarUrl for the local user
|
* @param {string} newAvatarUrl new avatarUrl for the local user
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user