Skip to content

Commit 79f9e47

Browse files
Simplify logic that calls start_app()
The new logic calls start_app() when all the extension javscript files have been loaded.
1 parent dcada3d commit 79f9e47

2 files changed

Lines changed: 6 additions & 13 deletions

File tree

deps/rabbitmq_management/priv/www/js/global.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,9 +647,6 @@ var disable_stats; // ...disable all stats, management only mode
647647
// Extensions write to this, the dispatcher maker reads it
648648
var dispatcher_modules = [];
649649

650-
// We need to know when all extension script files have loaded
651-
var extension_count;
652-
653650
// The dispatcher needs access to the Sammy app
654651
var app;
655652

deps/rabbitmq_management/priv/www/js/main.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ function renderWarningMessageInLoginStatus(oauth, message) {
7070

7171
function dispatcher_add(fun) {
7272
dispatcher_modules.push(fun);
73-
if (dispatcher_modules.length == extension_count) {
74-
start_app();
75-
}
7673
}
7774

7875
function dispatcher() {
@@ -237,9 +234,7 @@ function update_vhosts() {
237234

238235
function setup_extensions() {
239236
var extensions = JSON.parse(sync_get('/extensions'));
240-
extension_count = 0;
241237
var javascript_files = [];
242-
243238
for (var i in extensions) {
244239
var extension = extensions[i];
245240
if ($.isPlainObject(extension)) {
@@ -252,20 +247,21 @@ function setup_extensions() {
252247
} else {
253248
javascript_files.push(extension.javascript);
254249
}
255-
}
250+
}
256251
if (extension.hasOwnProperty('css')) {
257-
dynamic_css_load(extension.css);
252+
dynamic_css_load(extension.css);
258253
}
259-
extension_count++;
260254
}
261255
}
262-
// Load JavaScript files sequentially to ensure dependencies are available
256+
// Load JavaScript files sequentially; start_app() runs when all have loaded and registered
263257
load_javascript_files_sequentially(javascript_files, 0);
264258
}
265259

266260
function load_javascript_files_sequentially(files, index) {
267261
if (index >= files.length) {
268-
return; // All files loaded
262+
console.info("All extension are loaded. Starting app...");
263+
start_app();
264+
return;
269265
}
270266
console.debug(`Loading extension ${files[index]} ...`);
271267
dynamic_javascript_file_load(files[index], function() {

0 commit comments

Comments
 (0)