Skip to content
Snippets Groups Projects
Commit 1f3f6e92 authored by Felipe Cecagno's avatar Felipe Cecagno
Browse files

fixing the problem that was preventing the client to load the default layouts...

fixing the problem that was preventing the client to load the default layouts in the beginning of the session; the combo was only populated if the layouts were loaded BEFORE the layout combo get created - now it works independently of the order that the elements get initialized
parent 00a0d1e8
No related branches found
No related tags found
No related merge requests found
......@@ -61,6 +61,7 @@ package org.bigbluebutton.modules.layout.managers
private var _applyCurrentLayoutTimer:Timer = new Timer(150,1);
private var _customLayoutsCount:int = 0;
private var _serverLayoutsLoaded:Boolean = false;
private var _comboLayoutCreated:Boolean = false;
private var _eventsToDelay:Array = new Array(MDIManagerEvent.WINDOW_RESTORE,
MDIManagerEvent.WINDOW_MINIMIZE,
MDIManagerEvent.WINDOW_MAXIMIZE);
......@@ -73,16 +74,28 @@ package org.bigbluebutton.modules.layout.managers
_sendCurrentLayoutUpdateTimer.addEventListener(TimerEvent.TIMER, function(e:TimerEvent):void {
sendLayoutUpdate(updateCurrentLayout());
});
}
}
/**
* There's a race condition when the layouts combo doesn't get populated
* with the server's layouts definition. The problem is that sometimes
* the layouts is loaded before the combo get created, and sometimes the
* combo is created first. We use two booleans to sync it and only dispatch
* the layouts to populate the list when both are created.
*/
public function loadServerLayouts(layoutUrl:String):void {
LogUtil.debug("LayoutManager: loading server layouts from " + layoutUrl);
var loader:LayoutLoader = new LayoutLoader();
loader.addEventListener(LayoutsLoadedEvent.LAYOUTS_LOADED_EVENT, function(e:LayoutsLoadedEvent):void {
if (e.success) {
_layouts = e.layouts;
if (_comboLayoutCreated) {
broadcastLayouts();
}
_serverLayoutsLoaded = true;
LogUtil.debug("LayoutManager: layouts loaded successfully");
LogUtil.debug("LayoutManager: layouts loaded successfully");
} else {
LogUtil.error("LayoutManager: layouts not loaded (" + e.error.message + ")");
}
......@@ -92,11 +105,16 @@ package org.bigbluebutton.modules.layout.managers
public function onComboLayoutCreated():void {
if (_serverLayoutsLoaded) {
var layoutsLoaded:LayoutsLoadedEvent = new LayoutsLoadedEvent();
layoutsLoaded.layouts = _layouts;
_globalDispatcher.dispatchEvent(layoutsLoaded);
broadcastLayouts();
}
_comboLayoutCreated = true;
}
private function broadcastLayouts():void {
var layoutsLoaded:LayoutsLoadedEvent = new LayoutsLoadedEvent();
layoutsLoaded.layouts = _layouts;
_globalDispatcher.dispatchEvent(layoutsLoaded);
}
public function saveLayoutsToFile():void {
var _fileRef:FileReference = new FileReference();
......@@ -111,13 +129,8 @@ package org.bigbluebutton.modules.layout.managers
loader.addEventListener(LayoutsLoadedEvent.LAYOUTS_LOADED_EVENT, function(e:LayoutsLoadedEvent):void {
if (e.success) {
_layouts = e.layouts;
/*
* \TODO why do I need to create a new Event for this?
*/
var layoutsLoaded:LayoutsLoadedEvent = new LayoutsLoadedEvent();
layoutsLoaded.layouts = _layouts;
_globalDispatcher.dispatchEvent(layoutsLoaded);
broadcastLayouts();
/*
* it will update the ComboBox label, and will go back to this class
......@@ -356,5 +369,5 @@ package org.bigbluebutton.modules.layout.managers
if (_canvas != null)
applyLayout(_currentLayout);
}
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment