diff --git a/frontend/src/organisms/connection/host/logs.svelte b/frontend/src/organisms/connection/host/logs.svelte index e5ee5bf..802b500 100644 --- a/frontend/src/organisms/connection/host/logs.svelte +++ b/frontend/src/organisms/connection/host/logs.svelte @@ -4,6 +4,7 @@ import ObjectViewer from '$components/objectviewer.svelte'; import input from '$lib/actions/input'; import { BrowserOpenURL } from '$wails/runtime/runtime'; + import { onDestroy } from 'svelte'; export let host; @@ -15,9 +16,17 @@ let copySucceeded = false; let autoReloadInterval = 0; let objectViewerData; + let interval; $: filter && refresh(); $: busy = !logs && !error && 'Requesting logsā¦'; + $: if (autoReloadInterval) { + if (interval) { + clearInterval(interval); + } + interval = setInterval(refresh, autoReloadInterval * 1000); + } + async function refresh() { let _logs = []; ({ logs: _logs, total, error } = await host.getLogs(filter)); @@ -44,6 +53,12 @@ copySucceeded = true; setTimeout(() => copySucceeded = false, 1500); } + + onDestroy(() => { + if (interval) { + clearInterval(interval); + } + });