From 5dffddceec213c638e4b76afc120c766397becfb Mon Sep 17 00:00:00 2001 From: damencho Date: Wed, 6 Jul 2016 13:26:27 -0500 Subject: [PATCH] Make sure we have only one dialog instance. --- modules/UI/recording/Recording.js | 44 ++++++++++++++++++++------ modules/UI/shared_video/SharedVideo.js | 35 ++++++++++++++++---- 2 files changed, 64 insertions(+), 15 deletions(-) diff --git a/modules/UI/recording/Recording.js b/modules/UI/recording/Recording.js index 261687ff4..ecdb58355 100644 --- a/modules/UI/recording/Recording.js +++ b/modules/UI/recording/Recording.js @@ -21,6 +21,10 @@ import Feedback from '../Feedback.js'; import Toolbar from '../toolbars/Toolbar'; import BottomToolbar from '../toolbars/BottomToolbar'; +/** + * The dialog for user input. + */ +let dialog = null; /** * Indicates if the recording button should be enabled. @@ -50,7 +54,7 @@ function _requestLiveStreamId() { "liveStreaming.streamIdRequired"); return new Promise(function (resolve, reject) { - let dialog = APP.UI.messageHandler.openDialogWithStates({ + dialog = APP.UI.messageHandler.openDialogWithStates({ state0: { html: `

${msg}

@@ -104,6 +108,10 @@ function _requestLiveStreamId() { } } } + }, { + close: function () { + dialog = null; + } }); }); } @@ -117,7 +125,7 @@ function _requestRecordingToken () { let token = APP.translation.translateString("dialog.token"); return new Promise(function (resolve, reject) { - APP.UI.messageHandler.openTwoButtonDialog( + dialog = APP.UI.messageHandler.openTwoButtonDialog( null, null, null, `

${msg}

- self.eventEmitter.emit(UIEvents.RECORDING_TOGGLED)); + self.eventEmitter.emit(UIEvents.RECORDING_TOGGLED), + () => {}); break; } case Status.AVAILABLE: @@ -318,16 +336,24 @@ var Recording = { break; } case Status.BUSY: { - APP.UI.messageHandler.openMessageDialog( + dialog = APP.UI.messageHandler.openMessageDialog( self.recordingTitle, - self.recordingBusy + self.recordingBusy, + null, null, + function () { + dialog = null; + } ); break; } default: { - APP.UI.messageHandler.openMessageDialog( + dialog = APP.UI.messageHandler.openMessageDialog( self.recordingTitle, - self.recordingUnavailable + self.recordingUnavailable, + null, null, + function () { + dialog = null; + } ); } } diff --git a/modules/UI/shared_video/SharedVideo.js b/modules/UI/shared_video/SharedVideo.js index 827334718..562e9d981 100644 --- a/modules/UI/shared_video/SharedVideo.js +++ b/modules/UI/shared_video/SharedVideo.js @@ -17,6 +17,13 @@ export const SHARED_VIDEO_CONTAINER_TYPE = "sharedvideo"; */ const defaultSharedVideoLink = "https://www.youtube.com/watch?v=xNXN7CZk8X0"; const updateInterval = 5000; // milliseconds + +/** + * The dialog for user input (video link). + * @type {null} + */ +let dialog = null; + /** * Manager of shared video. */ @@ -56,11 +63,14 @@ export default class SharedVideoManager { * asks whether the user wants to stop sharing the video. */ toggleSharedVideo () { + if (dialog) + return; + if(!this.isSharedVideoShown) { requestVideoLink().then( url => this.emitter.emit( UIEvents.UPDATE_SHARED_VIDEO, url, 'start'), - err => console.error('SHARED VIDEO CANCELED', err) + err => console.log('SHARED VIDEO CANCELED', err) ); return; } @@ -68,11 +78,16 @@ export default class SharedVideoManager { if(APP.conference.isLocalId(this.from)) { showStopVideoPropmpt().then(() => this.emitter.emit( - UIEvents.UPDATE_SHARED_VIDEO, this.url, 'stop')); + UIEvents.UPDATE_SHARED_VIDEO, this.url, 'stop'), + () => {}); } else { - APP.UI.messageHandler.openMessageDialog( + dialog = APP.UI.messageHandler.openMessageDialog( "dialog.shareVideoTitle", - "dialog.alreadySharedVideoMsg" + "dialog.alreadySharedVideoMsg", + null, null, + function () { + dialog = null; + } ); } } @@ -700,7 +715,7 @@ function getYoutubeLink(url) { */ function showStopVideoPropmpt() { return new Promise(function (resolve, reject) { - APP.UI.messageHandler.openTwoButtonDialog( + dialog = APP.UI.messageHandler.openTwoButtonDialog( "dialog.removeSharedVideoTitle", null, "dialog.removeSharedVideoMsg", @@ -713,6 +728,10 @@ function showStopVideoPropmpt() { } else { reject(); } + }, + null, + function () { + dialog = null; } ); @@ -735,7 +754,7 @@ function requestVideoLink() { const defaultUrl = i18n.translateString("defaultLink", i18nOptions); return new Promise(function (resolve, reject) { - let dialog = APP.UI.messageHandler.openDialogWithStates({ + dialog = APP.UI.messageHandler.openDialogWithStates({ state0: { html: `

${title}

@@ -795,6 +814,10 @@ function requestVideoLink() { } } } + }, { + close: function () { + dialog = null; + } }); });