Make sure we have only one dialog instance.
This commit is contained in:
parent
d5de49b5cf
commit
5dffddceec
|
@ -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:
|
||||
`<h2>${msg}</h2>
|
||||
|
@ -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,
|
||||
`<h2>${msg}</h2>
|
||||
<input name="recordingToken" type="text"
|
||||
|
@ -132,7 +140,9 @@ function _requestRecordingToken () {
|
|||
}
|
||||
},
|
||||
null,
|
||||
function () { },
|
||||
function () {
|
||||
dialog = null;
|
||||
},
|
||||
':input:first'
|
||||
);
|
||||
});
|
||||
|
@ -161,7 +171,7 @@ function _showStopRecordingPrompt (recordingType) {
|
|||
}
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
APP.UI.messageHandler.openTwoButtonDialog(
|
||||
dialog = APP.UI.messageHandler.openTwoButtonDialog(
|
||||
title,
|
||||
null,
|
||||
message,
|
||||
|
@ -174,6 +184,10 @@ function _showStopRecordingPrompt (recordingType) {
|
|||
} else {
|
||||
reject();
|
||||
}
|
||||
},
|
||||
null,
|
||||
function () {
|
||||
dialog = null;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -279,11 +293,15 @@ var Recording = {
|
|||
|
||||
var self = this;
|
||||
selector.click(function () {
|
||||
if (dialog)
|
||||
return;
|
||||
|
||||
switch (self.currentState) {
|
||||
case Status.ON:
|
||||
case Status.PENDING: {
|
||||
_showStopRecordingPrompt(recordingType).then(() =>
|
||||
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;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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: `
|
||||
<h2>${title}</h2>
|
||||
|
@ -795,6 +814,10 @@ function requestVideoLink() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
close: function () {
|
||||
dialog = null;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue