diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index ab98abc..48cfd8a 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -14,8 +14,20 @@ let isConnected = client.isConnected; let klippyState = moonraker.klippyState.state; let isFullscreen = bootParams.fullscreen; + let wsUrl = bootParams.moonrakerWs; + let interval: NodeJS.Timeout; $: { + if ($isConnected) { + clearInterval(interval); + } else { + clearInterval(interval); + interval = setInterval(async () => { + //await moonraker.disconnect(); + await moonraker.connect($wsUrl); + }, 5000); + } + if ($isConnected === false || $klippyState !== 'ready') { goto('/'); } diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 1fa74a2..c9f4498 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -2,7 +2,7 @@ import { bootParams, client, commands, moonraker } from '$lib/base.svelte'; let wsUrl = bootParams.moonrakerWs; - + let apiUrl = bootParams.moonrakerApi; let isConnected = client.isConnected; let klippyState = moonraker.klippyState.state; let klippyStateMessage = moonraker.klippyState.message; @@ -52,7 +52,15 @@ {:else}