fix(conference): initialize UI features on CONFERENCE_JOINED

Initializing UI features, like keyboard shortcuts, by chaining
onto APP.conference.init is not safe because init can fail,
skipping the initializing of UI features. This can happen when
the room is locked and then a failure event is dispatched into
middleware. I couldn't find a place to properly chain onto
in the APP.conference.init promise chain, primarily due
to the flow continued within middleware, so instead I
leveraged an existing listener for CONFERENCE_JOINED.
This commit is contained in:
Leonard Kim 2017-11-16 14:54:49 -08:00 committed by hristoterezov
parent 03e68b0e4b
commit bb45f76a7a
2 changed files with 58 additions and 49 deletions

View File

@ -1702,11 +1702,7 @@ export default {
_setupListeners() {
// add local streams when joined to the conference
room.on(JitsiConferenceEvents.CONFERENCE_JOINED, () => {
APP.store.dispatch(conferenceJoined(room));
APP.UI.mucJoined();
APP.API.notifyConferenceJoined(APP.conference.roomName);
APP.UI.markVideoInterrupted(false);
this._onConferenceJoined();
});
room.on(
@ -2334,6 +2330,62 @@ export default {
});
},
/**
* Callback invoked when the conference has been successfully joined.
* Initializes the UI and various other features.
*
* @private
* @returns {void}
*/
_onConferenceJoined() {
if (APP.logCollector) {
// Start the LogCollector's periodic "store logs" task
APP.logCollector.start();
APP.logCollectorStarted = true;
// Make an attempt to flush in case a lot of logs have been
// cached, before the collector was started.
APP.logCollector.flush();
// This event listener will flush the logs, before
// the statistics module (CallStats) is stopped.
//
// NOTE The LogCollector is not stopped, because this event can
// be triggered multiple times during single conference
// (whenever statistics module is stopped). That includes
// the case when Jicofo terminates the single person left in the
// room. It will then restart the media session when someone
// eventually join the room which will start the stats again.
APP.conference.addConferenceListener(
JitsiConferenceEvents.BEFORE_STATISTICS_DISPOSED,
() => {
if (APP.logCollector) {
APP.logCollector.flush();
}
}
);
}
APP.UI.initConference();
APP.UI.addListener(
UIEvents.LANG_CHANGED,
language => APP.translation.setLanguage(language));
APP.keyboardshortcut.init();
if (config.requireDisplayName
&& !APP.conference.getLocalDisplayName()) {
APP.UI.promptDisplayName();
}
APP.store.dispatch(conferenceJoined(room));
APP.UI.mucJoined();
APP.API.notifyConferenceJoined(APP.conference.roomName);
APP.UI.markVideoInterrupted(false);
},
/**
* Adds any room listener.
* @param {string} eventName one of the JitsiConferenceEvents

View File

@ -3,12 +3,10 @@
import type { Dispatch } from 'redux';
import {
JitsiConferenceEvents,
libInitError,
WEBRTC_NOT_READY,
WEBRTC_NOT_SUPPORTED
} from '../lib-jitsi-meet';
import UIEvents from '../../../../service/UI/UIEvents';
declare var APP: Object;
declare var config: Object;
@ -35,48 +33,7 @@ export function connect() {
// XXX For web based version we use conference initialization logic
// from the old app (at the moment of writing).
return APP.conference.init({ roomName: room }).then(() => {
if (APP.logCollector) {
// Start the LogCollector's periodic "store logs" task
APP.logCollector.start();
APP.logCollectorStarted = true;
// Make an attempt to flush in case a lot of logs have been
// cached, before the collector was started.
APP.logCollector.flush();
// This event listener will flush the logs, before
// the statistics module (CallStats) is stopped.
//
// NOTE The LogCollector is not stopped, because this event can
// be triggered multiple times during single conference
// (whenever statistics module is stopped). That includes
// the case when Jicofo terminates the single person left in the
// room. It will then restart the media session when someone
// eventually join the room which will start the stats again.
APP.conference.addConferenceListener(
JitsiConferenceEvents.BEFORE_STATISTICS_DISPOSED,
() => {
if (APP.logCollector) {
APP.logCollector.flush();
}
}
);
}
APP.UI.initConference();
APP.UI.addListener(
UIEvents.LANG_CHANGED,
language => APP.translation.setLanguage(language));
APP.keyboardshortcut.init();
if (config.requireDisplayName
&& !APP.conference.getLocalDisplayName()) {
APP.UI.promptDisplayName();
}
})
return APP.conference.init({ roomName: room })
.catch(error => {
APP.API.notifyConferenceLeft(APP.conference.roomName);
logger.error(error);