Skip to content

Commit

Permalink
Add auto refresh script on server restart
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Jacobsen Work committed Jul 19, 2023
1 parent 58ce274 commit 2eb0a11
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions BLAZAM/Pages/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,23 @@
<script src="~/js/blazam.js"></script>
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
<script src="_content/MudBlazor.Markdown/MudBlazor.Markdown.min.js"></script>

<script>
// Wait until a 'reload' button appears
new MutationObserver((mutations, observer) => {
if (document.querySelector('#components-reconnect-modal h5 a')) {
// Now every 10 seconds, see if the server appears to be back, and if so, reload
async function attemptReload() {
await fetch(''); // Check the server really is back
location.reload();
}
observer.disconnect();
attemptReload();
setInterval(attemptReload, 10000);
}
}).observe(document.body, { childList: true, subtree: true });
</script>


</body>
</html>

0 comments on commit 2eb0a11

Please sign in to comment.