app_store: make widget retry every second if initial fetch fails

This commit is contained in:
dr-frmr 2024-09-18 15:31:40 -04:00
parent 31f73db0b0
commit 85f22776f1
No known key found for this signature in database

View File

@ -139,10 +139,12 @@ fn make_widget() -> String {
<div id="latest-apps"></div>
<script>
document.addEventListener('DOMContentLoaded', function() {
function fetchApps() {
fetch('/main:app_store:sys/apps', { credentials: 'include' })
.then(response => response.json())
.then(data => {
const container = document.getElementById('latest-apps');
container.innerHTML = '';
data.forEach(app => {
if (app.metadata) {
const a = document.createElement('a');
@ -165,7 +167,13 @@ fn make_widget() -> String {
}
});
})
.catch(error => console.error('Error fetching apps:', error));
.catch(error => {
console.error('Error fetching apps:', error);
setTimeout(fetchApps, 1000); // Retry after a second
});
}
fetchApps();
});
</script>
</body>