Skip to content

Commit d003667

Browse files
author
veeck
committed
Make startModules async
1 parent 70dce61 commit d003667

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

js/loader.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ const Loader = (function () {
3333
// overwrite all the defined styles.
3434
await loadFile(config.customCss);
3535
// custom.css loaded. Start all modules.
36-
startModules();
36+
await startModules();
3737
}
3838
};
3939

4040
await loadNextModule();
4141
};
4242

4343
/**
44-
* Loops thru all modules and requests start for every module.
44+
* Loops through all modules and requests start for every module.
4545
*/
46-
const startModules = function () {
46+
const startModules = async function () {
4747
const modulePromises = [];
4848
for (const module of moduleObjects) {
4949
try {
@@ -54,25 +54,25 @@ const Loader = (function () {
5454
}
5555
}
5656

57-
Promise.allSettled(modulePromises).then((results) => {
58-
// Log errors that happened during async node_helper startup
59-
results.forEach((result) => {
60-
if (result.status === "rejected") {
61-
Log.error(result.reason);
62-
}
63-
});
64-
65-
// Notify core of loaded modules.
66-
MM.modulesStarted(moduleObjects);
57+
const results = Promise.allSettled(modulePromises);
6758

68-
// Starting modules also hides any modules that have requested to be initially hidden
69-
for (const thisModule of moduleObjects) {
70-
if (thisModule.data.hiddenOnStartup) {
71-
Log.info("Initially hiding " + thisModule.name);
72-
thisModule.hide();
73-
}
59+
// Log errors that happened during async node_helper startup
60+
results.forEach((result) => {
61+
if (result.status === "rejected") {
62+
Log.error(result.reason);
7463
}
7564
});
65+
66+
// Notify core of loaded modules.
67+
MM.modulesStarted(moduleObjects);
68+
69+
// Starting modules also hides any modules that have requested to be initially hidden
70+
for (const thisModule of moduleObjects) {
71+
if (thisModule.data.hiddenOnStartup) {
72+
Log.info("Initially hiding " + thisModule.name);
73+
thisModule.hide();
74+
}
75+
}
7676
};
7777

7878
/**

0 commit comments

Comments
 (0)