|
@@ -16,7 +16,6 @@ import mediaDeviceHelper from './modules/devices/mediaDeviceHelper';
|
16
|
16
|
|
17
|
17
|
import {reportError} from './modules/util/helpers';
|
18
|
18
|
|
19
|
|
-import UIErrors from './modules/UI/UIErrors';
|
20
|
19
|
import UIUtil from './modules/UI/util/UIUtil';
|
21
|
20
|
|
22
|
21
|
const ConnectionErrors = JitsiMeetJS.errors.connection;
|
|
@@ -42,7 +41,7 @@ let DSExternalInstallationInProgress = false;
|
42
|
41
|
/**
|
43
|
42
|
* Listens whether conference had been left from local user when we are trying
|
44
|
43
|
* to navigate away from current page.
|
45
|
|
- * @type {ConferenceLeftListener}
|
|
44
|
+ * @type {HangupConferenceLeftListener}
|
46
|
45
|
*/
|
47
|
46
|
let conferenceLeftListener = null;
|
48
|
47
|
|
|
@@ -220,104 +219,47 @@ function maybeRedirectToWelcomePage(showThankYou) {
|
220
|
219
|
}, 3000);
|
221
|
220
|
}
|
222
|
221
|
|
223
|
|
-/**
|
224
|
|
- * Executes connection.disconnect and shows the feedback dialog
|
225
|
|
- * @param {boolean} [requestFeedback=false] if user feedback should be requested
|
226
|
|
- * @returns Promise.
|
227
|
|
- */
|
228
|
|
-function disconnectAndShowFeedback(requestFeedback) {
|
229
|
|
- APP.UI.hideRingOverLay();
|
230
|
|
- connection.disconnect();
|
231
|
|
- APP.API.notifyConferenceLeft(APP.conference.roomName);
|
232
|
|
- if (requestFeedback) {
|
233
|
|
- return APP.UI.requestFeedback();
|
234
|
|
- } else {
|
235
|
|
- return Promise.resolve();
|
236
|
|
- }
|
237
|
|
-}
|
238
|
222
|
|
239
|
223
|
/**
|
240
|
|
- * Disconnect from the conference and optionally request user feedback.
|
241
|
|
- * @param {boolean} [requestFeedback=false] if user feedback should be requested
|
|
224
|
+ * Listens for CONFERENCE_LEFT event after hangup function has been executed.
|
242
|
225
|
*/
|
243
|
|
-function hangup (requestFeedback = false) {
|
244
|
|
- const errCallback = (err) => {
|
245
|
|
-
|
246
|
|
- // If we want to break out the chain in our error handler, it needs
|
247
|
|
- // to return a rejected promise. In the case of feedback request
|
248
|
|
- // in progress it's important to not redirect to the welcome page
|
249
|
|
- // (see below maybeRedirectToWelcomePage call).
|
250
|
|
- if (err === UIErrors.FEEDBACK_REQUEST_IN_PROGRESS) {
|
251
|
|
- return Promise.reject('Feedback request in progress.');
|
252
|
|
- }
|
253
|
|
- else {
|
254
|
|
- console.error('Error occurred during hanging up: ', err);
|
255
|
|
- return Promise.resolve();
|
256
|
|
- }
|
257
|
|
- };
|
258
|
|
- const disconnect = disconnectAndShowFeedback.bind(null, requestFeedback);
|
259
|
|
-
|
260
|
|
- if (!conferenceLeftListener)
|
261
|
|
- conferenceLeftListener = new ConferenceLeftListener();
|
262
|
|
-
|
263
|
|
- // Make sure that leave is resolved successfully and the set the handlers
|
264
|
|
- // to be invoked once conference had been left
|
265
|
|
- APP.conference._room.leave()
|
266
|
|
- .then(conferenceLeftListener.setHandler(disconnect, errCallback))
|
267
|
|
- .catch(errCallback);
|
268
|
|
-}
|
269
|
|
-
|
270
|
|
-/**
|
271
|
|
- * Listens for CONFERENCE_LEFT event so we can check whether it has finished.
|
272
|
|
- * The handler will be called once the conference had been left or if it
|
273
|
|
- * was already left when we are adding the handler.
|
274
|
|
- */
|
275
|
|
-class ConferenceLeftListener {
|
|
226
|
+class HangupConferenceLeftListener {
|
276
|
227
|
/**
|
277
|
|
- * Creates ConferenceLeftListener and start listening for conference
|
278
|
|
- * failed event.
|
|
228
|
+ * Creates HangupConferenceLeftListener and start listening for conference
|
|
229
|
+ * left event. On CONFERENCE_LEFT event calls should disconnect the user
|
|
230
|
+ * and maybe show the feedback dialog.
|
|
231
|
+ * @param {boolean} [requestFeedback=false] if user feedback should be
|
|
232
|
+ * requested
|
279
|
233
|
*/
|
280
|
|
- constructor() {
|
|
234
|
+ constructor(requestFeedback) {
|
|
235
|
+ this.requestFeedback = requestFeedback;
|
281
|
236
|
room.on(ConferenceEvents.CONFERENCE_LEFT,
|
282
|
237
|
this._handleConferenceLeft.bind(this));
|
283
|
238
|
}
|
284
|
239
|
|
285
|
240
|
/**
|
286
|
|
- * Handles the conference left event, if we have a handler we invoke it.
|
|
241
|
+ * Handles the conference left event.
|
287
|
242
|
* @private
|
288
|
243
|
*/
|
289
|
244
|
_handleConferenceLeft() {
|
290
|
|
- this.conferenceLeft = true;
|
291
|
|
-
|
292
|
|
- if (this.handler)
|
293
|
|
- this._handleLeave();
|
294
|
|
- }
|
295
|
|
-
|
296
|
|
- /**
|
297
|
|
- * Sets the handlers. If we already left the conference invoke them.
|
298
|
|
- * @param handler
|
299
|
|
- * @param errCallback
|
300
|
|
- */
|
301
|
|
- setHandler (handler, errCallback) {
|
302
|
|
- this.handler = handler;
|
303
|
|
- this.errCallback = errCallback;
|
304
|
|
-
|
305
|
|
- if (this.conferenceLeft)
|
306
|
|
- this._handleLeave();
|
|
245
|
+ this._disconnectAndShowFeedback()
|
|
246
|
+ .then(() => {
|
|
247
|
+ APP.API.notifyReadyToClose();
|
|
248
|
+ maybeRedirectToWelcomePage();
|
|
249
|
+ }).catch(console.log);
|
307
|
250
|
}
|
308
|
251
|
|
309
|
252
|
/**
|
310
|
|
- * Invokes the handlers.
|
|
253
|
+ * Executes connection.disconnect and shows the feedback dialog
|
|
254
|
+ * @returns Promise.
|
311
|
255
|
* @private
|
312
|
256
|
*/
|
313
|
|
- _handleLeave()
|
314
|
|
- {
|
315
|
|
- this.handler()
|
316
|
|
- .catch(this.errCallback)
|
317
|
|
- .then(maybeRedirectToWelcomePage)
|
318
|
|
- .catch(function(err){
|
319
|
|
- console.log(err);
|
320
|
|
- });
|
|
257
|
+ _disconnectAndShowFeedback() {
|
|
258
|
+ APP.UI.hideRingOverLay();
|
|
259
|
+ connection.disconnect();
|
|
260
|
+ APP.API.notifyConferenceLeft(APP.conference.roomName);
|
|
261
|
+ return (this.requestFeedback) ?
|
|
262
|
+ APP.UI.requestFeedback() : Promise.resolve();
|
321
|
263
|
}
|
322
|
264
|
}
|
323
|
265
|
|
|
@@ -1477,16 +1419,16 @@ export default {
|
1477
|
1419
|
|
1478
|
1420
|
// call hangup
|
1479
|
1421
|
APP.UI.addListener(UIEvents.HANGUP, () => {
|
1480
|
|
- hangup(true);
|
|
1422
|
+ this.hangup(true);
|
1481
|
1423
|
});
|
1482
|
1424
|
|
1483
|
1425
|
// logout
|
1484
|
1426
|
APP.UI.addListener(UIEvents.LOGOUT, () => {
|
1485
|
|
- AuthHandler.logout(room).then(function (url) {
|
|
1427
|
+ AuthHandler.logout(room).then(url => {
|
1486
|
1428
|
if (url) {
|
1487
|
1429
|
window.location.href = url;
|
1488
|
1430
|
} else {
|
1489
|
|
- hangup(true);
|
|
1431
|
+ this.hangup(true);
|
1490
|
1432
|
}
|
1491
|
1433
|
});
|
1492
|
1434
|
});
|
|
@@ -1827,5 +1769,20 @@ export default {
|
1827
|
1769
|
if(room) {
|
1828
|
1770
|
room.sendApplicationLog(JSON.stringify({name, value}));
|
1829
|
1771
|
}
|
|
1772
|
+ },
|
|
1773
|
+ /**
|
|
1774
|
+ * Disconnect from the conference and optionally request user feedback.
|
|
1775
|
+ * @param {boolean} [requestFeedback=false] if user feedback should be
|
|
1776
|
+ * requested
|
|
1777
|
+ */
|
|
1778
|
+ hangup (requestFeedback = false) {
|
|
1779
|
+ if (!conferenceLeftListener) {
|
|
1780
|
+ conferenceLeftListener
|
|
1781
|
+ = new HangupConferenceLeftListener(requestFeedback);
|
|
1782
|
+ }
|
|
1783
|
+
|
|
1784
|
+ //FIXME: Do something for the use case when we are not receiving
|
|
1785
|
+ // CONFERENCE_LEFT for some reason
|
|
1786
|
+ room.leave();
|
1830
|
1787
|
}
|
1831
|
1788
|
};
|