mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2025-05-19 10:32:56 +00:00
implemented retry mechanism for loading config data after esp restart
This commit is contained in:
parent
ecfa24a2d7
commit
4d58f864d0
1 changed files with 12 additions and 10 deletions
|
@ -55,18 +55,20 @@ export async function updateConfig(fetchOptions) {
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw new Error(`Response status: ${res.status}`);
|
throw new Error(`Response status: ${res.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for the esp to restart
|
|
||||||
const delay = new Promise((resolve) =>
|
|
||||||
setTimeout(() => resolve(), 5000)
|
|
||||||
);
|
|
||||||
await delay;
|
|
||||||
|
|
||||||
const data = await loadData(30 * 1000);
|
|
||||||
writeDataToInput(data);
|
|
||||||
hideLoadingScreen();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error.message);
|
console.error(error.message);
|
||||||
showError(error.message);
|
showError(error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
try {
|
||||||
|
const data = await loadData(5000);
|
||||||
|
writeDataToInput(data);
|
||||||
|
hideLoadingScreen();
|
||||||
|
|
||||||
|
break;
|
||||||
|
} catch (error) {
|
||||||
|
// retry loading config until successful
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue