fix(frame_api): toggle SS race condition
If toggle SS is executed too early and lib-jitsi-meet is not yet initialized toggle SS will fail. Now we are storing the whether SS is on or off and when lib-jitsi-meet is ready we are starting SS if needed.
This commit is contained in:
parent
1ec06f4bf0
commit
e7a3ee477d
|
@ -2,3 +2,10 @@
|
||||||
* Notifies interested parties that hangup procedure will start.
|
* Notifies interested parties that hangup procedure will start.
|
||||||
*/
|
*/
|
||||||
export const BEFORE_HANGUP = "conference.before_hangup";
|
export const BEFORE_HANGUP = "conference.before_hangup";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies interested parties that desktop sharing enable/disable state is
|
||||||
|
* changed.
|
||||||
|
*/
|
||||||
|
export const DESKTOP_SHARING_ENABLED_CHANGED
|
||||||
|
= "conference.desktop_sharing_enabled_changed";
|
||||||
|
|
|
@ -588,6 +588,9 @@ export default {
|
||||||
APP.connection = connection = con;
|
APP.connection = connection = con;
|
||||||
this.isDesktopSharingEnabled =
|
this.isDesktopSharingEnabled =
|
||||||
JitsiMeetJS.isDesktopSharingEnabled();
|
JitsiMeetJS.isDesktopSharingEnabled();
|
||||||
|
eventEmitter.emit(
|
||||||
|
JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
|
||||||
|
this.isDesktopSharingEnabled);
|
||||||
|
|
||||||
APP.store.dispatch(showDesktopSharingButton());
|
APP.store.dispatch(showDesktopSharingButton());
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
import postisInit from 'postis';
|
import postisInit from 'postis';
|
||||||
|
|
||||||
|
import * as JitsiMeetConferenceEvents from '../../ConferenceEvents';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of the available commands.
|
* List of the available commands.
|
||||||
* @type {{
|
* @type {{
|
||||||
|
@ -43,6 +45,25 @@ let postis;
|
||||||
*/
|
*/
|
||||||
let enabled = false;
|
let enabled = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The state of screen sharing(started/stopped) before the screen sharing is
|
||||||
|
* enabled and initialized.
|
||||||
|
* NOTE: This flag help us to cache the state and use it if toggle-share-screen
|
||||||
|
* was received before the initialization.
|
||||||
|
*/
|
||||||
|
let initialScreenSharingState = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes on toggle-share-screen command.
|
||||||
|
*/
|
||||||
|
function toggleScreenSharing() {
|
||||||
|
if(!APP.conference.isDesktopSharingEnabled) {
|
||||||
|
initialScreenSharingState = !initialScreenSharingState;
|
||||||
|
} else {
|
||||||
|
APP.conference.toggleScreenSharing();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function initCommands() {
|
function initCommands() {
|
||||||
commands = {
|
commands = {
|
||||||
"display-name":
|
"display-name":
|
||||||
|
@ -52,8 +73,7 @@ function initCommands() {
|
||||||
"toggle-film-strip": APP.UI.toggleFilmstrip,
|
"toggle-film-strip": APP.UI.toggleFilmstrip,
|
||||||
"toggle-chat": APP.UI.toggleChat,
|
"toggle-chat": APP.UI.toggleChat,
|
||||||
"toggle-contact-list": APP.UI.toggleContactList,
|
"toggle-contact-list": APP.UI.toggleContactList,
|
||||||
"toggle-share-screen":
|
"toggle-share-screen": toggleScreenSharing,
|
||||||
APP.conference.toggleScreenSharing.bind(APP.conference),
|
|
||||||
"video-hangup": () => APP.conference.hangup(),
|
"video-hangup": () => APP.conference.hangup(),
|
||||||
"email": APP.conference.changeLocalEmail,
|
"email": APP.conference.changeLocalEmail,
|
||||||
"avatar-url": APP.conference.changeLocalAvatarUrl,
|
"avatar-url": APP.conference.changeLocalAvatarUrl,
|
||||||
|
@ -97,6 +117,19 @@ function triggerEvent (name, object) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listens for screen sharing enabled events and toggles the screen sharing if
|
||||||
|
* needed.
|
||||||
|
*
|
||||||
|
* @param {boolean} enabled - Current screen sharing enabled status.
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function onScreenSharingEnable(enabled = false) {
|
||||||
|
if(enabled && initialScreenSharingState) {
|
||||||
|
toggleScreenSharing();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class API {
|
class API {
|
||||||
/**
|
/**
|
||||||
* Constructs new instance
|
* Constructs new instance
|
||||||
|
@ -116,7 +149,12 @@ class API {
|
||||||
if(!shouldBeEnabled() && !options.forceEnable)
|
if(!shouldBeEnabled() && !options.forceEnable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
enabled = true;
|
if(!enabled) {
|
||||||
|
APP.conference.addListener(
|
||||||
|
JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
|
||||||
|
onScreenSharingEnable);
|
||||||
|
enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
if(!postis) {
|
if(!postis) {
|
||||||
this._initPostis();
|
this._initPostis();
|
||||||
|
@ -233,8 +271,12 @@ class API {
|
||||||
* Removes the listeners.
|
* Removes the listeners.
|
||||||
*/
|
*/
|
||||||
dispose () {
|
dispose () {
|
||||||
if(enabled)
|
if(enabled) {
|
||||||
postis.destroy();
|
postis.destroy();
|
||||||
|
APP.conference.removeListener(
|
||||||
|
JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
|
||||||
|
onScreenSharingEnable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue