Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

ref(conference.js): remove global promise

paweldomase7a4318e8c0e
diff --git a/conference.js b/conference.js
index 8cfed65b9d..d7301cf7e8 100644
--- a/conference.js
+++ b/conference.js
@@ -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)
diff --git a/modules/remotecontrol/Receiver.js b/modules/remotecontrol/Receiver.js
index 76c5d1d22c..f84539f32c 100644
--- a/modules/remotecontrol/Receiver.js
+++ b/modules/remotecontrol/Receiver.js
@@ -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
});
- });
}
}