last20messages aktualisieren mit setInterval
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
|
||||
export async function loadWindowVariables() {
|
||||
return new Promise((resolve, reject) => {
|
||||
// Überprüfen, ob die wichtigsten Variablen bereits geladen sind
|
||||
//console.log("Running loadWindowVariables..."); // Log each run
|
||||
|
||||
const requiredVars = [
|
||||
"last20Messages",
|
||||
"deviceName",
|
||||
@@ -44,17 +45,6 @@ export async function loadWindowVariables() {
|
||||
"appVersion",
|
||||
];
|
||||
|
||||
const missingVars = requiredVars.filter(
|
||||
(variable) => window[variable] === undefined
|
||||
);
|
||||
|
||||
// Wenn alle Variablen bereits vorhanden sind, auflösen und keine weiteren Skripte laden
|
||||
if (missingVars.length === 0) {
|
||||
console.log("Alle Systemvariablen sind bereits geladen.");
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const loadScript = (src) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const script = document.createElement("script");
|
||||
@@ -70,7 +60,6 @@ export async function loadWindowVariables() {
|
||||
});
|
||||
};
|
||||
|
||||
// Nur die fehlenden Skripte laden
|
||||
const scripts = [
|
||||
"de.js",
|
||||
"kueConfig.js",
|
||||
@@ -80,13 +69,28 @@ export async function loadWindowVariables() {
|
||||
"System.js",
|
||||
];
|
||||
|
||||
// Load all required scripts
|
||||
Promise.all(scripts.map(loadScript))
|
||||
.then(() => {
|
||||
console.log("Alle Systemvariablen wurden erfolgreich geladen.");
|
||||
resolve();
|
||||
// console.log("Scripts loaded. Checking for variables...");
|
||||
|
||||
// Interval to check if all required variables are loaded
|
||||
const checkInterval = setInterval(() => {
|
||||
const missingVars = requiredVars.filter(
|
||||
(variable) => window[variable] === undefined
|
||||
);
|
||||
|
||||
if (missingVars.length === 0) {
|
||||
//console.log("All system variables are now loaded.");
|
||||
clearInterval(checkInterval);
|
||||
resolve();
|
||||
} else {
|
||||
console.log("Waiting for missing variables:", missingVars);
|
||||
}
|
||||
}, 5000); // Check every 5 seconds
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Fehler beim Laden eines Skripts:", error);
|
||||
console.error("Error loading a script:", error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user