Merge remote-tracking branch 'origin/master'

This commit is contained in:
Lyubomir Marinov 2016-10-13 13:33:37 -05:00
commit ce9fff2a8d
2 changed files with 35 additions and 63 deletions

View File

@ -38,13 +38,6 @@ let connectionIsInterrupted = false;
*/
let DSExternalInstallationInProgress = false;
/**
* Listens whether conference had been left from local user when we are trying
* to navigate away from current page.
* @type {HangupConferenceLeftListener}
*/
let conferenceLeftListener = null;
import {VIDEO_CONTAINER_TYPE} from "./modules/UI/videolayout/VideoContainer";
/**
@ -219,50 +212,6 @@ function maybeRedirectToWelcomePage(showThankYou) {
}, 3000);
}
/**
* Listens for CONFERENCE_LEFT event after hangup function has been executed.
*/
class HangupConferenceLeftListener {
/**
* Creates HangupConferenceLeftListener and start listening for conference
* left event. On CONFERENCE_LEFT event calls should disconnect the user
* and maybe show the feedback dialog.
* @param {boolean} [requestFeedback=false] if user feedback should be
* requested
*/
constructor(requestFeedback) {
this.requestFeedback = requestFeedback;
room.on(ConferenceEvents.CONFERENCE_LEFT,
this._handleConferenceLeft.bind(this));
}
/**
* Handles the conference left event.
* @private
*/
_handleConferenceLeft() {
this._disconnectAndShowFeedback()
.then(() => {
APP.API.notifyReadyToClose();
maybeRedirectToWelcomePage();
}).catch(console.log);
}
/**
* Executes connection.disconnect and shows the feedback dialog
* @returns Promise.
* @private
*/
_disconnectAndShowFeedback() {
APP.UI.hideRingOverLay();
connection.disconnect();
APP.API.notifyConferenceLeft(APP.conference.roomName);
return (this.requestFeedback) ?
APP.UI.requestFeedback() : Promise.resolve();
}
}
/**
* Create local tracks of specified types.
* @param {Object} options
@ -486,6 +435,17 @@ function sendTokenDataStats() {
}
}
/**
* Disconnects the connection.
* @returns resolved Promise. We need this in order to make the Promise.all
* call in hangup() to resolve when all operations are finished.
*/
function disconnect() {
connection.disconnect();
APP.API.notifyConferenceLeft(APP.conference.roomName);
return Promise.resolve();
}
/**
* Set permanent ptoperties to analytics.
* NOTE: Has to be used after JitsiMeetJS.init. otherwise analytics will be
@ -1784,13 +1744,20 @@ export default {
* requested
*/
hangup (requestFeedback = false) {
if (!conferenceLeftListener) {
conferenceLeftListener
= new HangupConferenceLeftListener(requestFeedback);
}
//FIXME: Do something for the use case when we are not receiving
// CONFERENCE_LEFT for some reason
room.leave();
APP.UI.hideRingOverLay();
let requestFeedbackPromise = requestFeedback
? APP.UI.requestFeedback().catch(() => Promise.resolve())
: Promise.resolve();
// All promises are returning Promise.resolve to make Promise.all to
// be resolved when both Promises are finished. Otherwise Promise.all
// will reject on first rejected Promise and we can redirect the page
// before all operations are done.
Promise.all([
requestFeedbackPromise,
room.leave().then(disconnect, disconnect)
]).then(() => {
APP.API.notifyReadyToClose();
maybeRedirectToWelcomePage();
});
}
};

View File

@ -1,4 +1,4 @@
/* global MD5, config, interfaceConfig */
/* global MD5, config, interfaceConfig, APP */
let users = {};
@ -10,6 +10,12 @@ export default {
* @param val {string} value to be set
*/
_setUserProp: function (id, prop, val) {
// 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)) {
id = "local";
}
if(!val || (users[id] && users[id][prop] === val))
return;
if(!users[id])
@ -56,9 +62,8 @@ export default {
return 'images/avatar2.png';
}
if (!userId) {
console.error("Get avatar - id is undefined");
return null;
if (!userId || APP.conference.isLocalId(userId)) {
userId = "local";
}
let avatarId = null;