ref(conference.js): remove global promise

Get rid of global APP.conference.screenSharingPromise.
This commit is contained in:
paweldomas 2017-06-13 14:24:34 -05:00 committed by hristoterezov
parent 01ac394e92
commit e7a4318e8c
2 changed files with 28 additions and 21 deletions

View File

@ -1109,26 +1109,32 @@ export default {
},
videoSwitchInProgress: false,
/**
* Toggles between screensharing and camera video.
* @param {boolean} [shareScreen]
* @return {Promise.<T>}
*/
toggleScreenSharing(shareScreen = !this.isSharingScreen) {
if (this.videoSwitchInProgress) {
logger.warn("Switch in progress.");
return;
return Promise.reject('Switch in progress.');
}
if (!this.isDesktopSharingEnabled) {
logger.warn("Cannot toggle screen sharing: not supported.");
return;
return Promise.reject(
'Cannot toggle screen sharing: not supported.');
}
if (this.isAudioOnly()) {
this._displayAudioOnlyTooltip('screenShare');
return;
return Promise.reject('No screensharing in audio only mode');
}
this.videoSwitchInProgress = true;
let externalInstallation = false;
if (shareScreen) {
this.screenSharingPromise = createLocalTracks({
return createLocalTracks({
devices: ['desktop'],
desktopSharingExtensionExternalInstallation: {
interval: 500,
@ -1218,7 +1224,7 @@ export default {
});
} else {
APP.remoteControl.receiver.stop();
this.screenSharingPromise = createLocalTracks(
return createLocalTracks(
{ devices: ['video'] })
.then(
([stream]) => this.useVideoStream(stream)

View File

@ -261,25 +261,26 @@ export default class Receiver extends RemoteControlParticipant {
action: PERMISSIONS_ACTIONS.grant
});
} else {
APP.conference.toggleScreenSharing();
APP.conference.screenSharingPromise.then(() => {
if (APP.conference.isSharingScreen) {
this.sendRemoteControlEvent(userId, {
type: EVENT_TYPES.permissions,
action: PERMISSIONS_ACTIONS.grant
});
} else {
APP.conference.toggleScreenSharing()
.then(() => {
if (APP.conference.isSharingScreen) {
this.sendRemoteControlEvent(userId, {
type: EVENT_TYPES.permissions,
action: PERMISSIONS_ACTIONS.grant
});
} else {
this.sendRemoteControlEvent(userId, {
type: EVENT_TYPES.permissions,
action: PERMISSIONS_ACTIONS.error
});
}
})
.catch(() => {
this.sendRemoteControlEvent(userId, {
type: EVENT_TYPES.permissions,
action: PERMISSIONS_ACTIONS.error
});
}
}).catch(() => {
this.sendRemoteControlEvent(userId, {
type: EVENT_TYPES.permissions,
action: PERMISSIONS_ACTIONS.error
});
});
}
}