fix(iframe_api): Display name command race condition

If executeCommand('displayName') is executed before Jitsi Meet
is fully initialized some listeners were not added and the
display name was not changed.
pull/1440/head
hristoterezov 8 years ago
parent 08531ee675
commit 0ed39dad63
  1. 37
      conference.js
  2. 3
      modules/API/API.js

@ -348,23 +348,6 @@ function createLocalTracks (options, checkForPermissionPrompt) {
}); });
} }
/**
* Changes the display name for the local user
* @param nickname {string} the new display name
*/
function changeLocalDisplayName(nickname = '') {
const formattedNickname
= nickname.trim().substr(0, MAX_DISPLAY_NAME_LENGTH);
if (formattedNickname === APP.settings.getDisplayName()) {
return;
}
APP.settings.setDisplayName(formattedNickname);
room.setDisplayName(formattedNickname);
APP.UI.changeDisplayName(APP.conference.getMyUserId(), formattedNickname);
}
class ConferenceConnector { class ConferenceConnector {
constructor(resolve, reject, invite) { constructor(resolve, reject, invite) {
this._resolve = resolve; this._resolve = resolve;
@ -1505,7 +1488,8 @@ export default {
APP.UI.setUserAvatarID(from, data.value); APP.UI.setUserAvatarID(from, data.value);
}); });
APP.UI.addListener(UIEvents.NICKNAME_CHANGED, changeLocalDisplayName); APP.UI.addListener(UIEvents.NICKNAME_CHANGED,
this.changeLocalDisplayName.bind(this));
APP.UI.addListener(UIEvents.START_MUTED_CHANGED, APP.UI.addListener(UIEvents.START_MUTED_CHANGED,
(startAudioMuted, startVideoMuted) => { (startAudioMuted, startVideoMuted) => {
@ -1978,5 +1962,22 @@ export default {
*/ */
isInLastN (participantId) { isInLastN (participantId) {
return room.isInLastN(participantId); return room.isInLastN(participantId);
},
/**
* Changes the display name for the local user
* @param nickname {string} the new display name
*/
changeLocalDisplayName(nickname = '') {
const formattedNickname
= nickname.trim().substr(0, MAX_DISPLAY_NAME_LENGTH);
if (formattedNickname === APP.settings.getDisplayName()) {
return;
}
APP.settings.setDisplayName(formattedNickname);
room.setDisplayName(formattedNickname);
APP.UI.changeDisplayName(this.getMyUserId(),
formattedNickname);
} }
}; };

@ -45,7 +45,8 @@ let enabled = false;
function initCommands() { function initCommands() {
commands = { commands = {
"display-name": APP.UI.inputDisplayNameHandler, "display-name":
APP.conference.changeLocalDisplayName.bind(APP.conference),
"toggle-audio": APP.conference.toggleAudioMuted.bind(APP.conference), "toggle-audio": APP.conference.toggleAudioMuted.bind(APP.conference),
"toggle-video": APP.conference.toggleVideoMuted.bind(APP.conference), "toggle-video": APP.conference.toggleVideoMuted.bind(APP.conference),
"toggle-film-strip": APP.UI.toggleFilmStrip, "toggle-film-strip": APP.UI.toggleFilmStrip,

Loading…
Cancel
Save