1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-18 13:07:58 +00:00

Implement logs autoreload

This commit is contained in:
Romein van Buren 2023-07-01 15:08:00 +02:00
parent 1f8984766b
commit 49d5022027
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49

View File

@ -4,6 +4,7 @@
import ObjectViewer from '$components/objectviewer.svelte'; import ObjectViewer from '$components/objectviewer.svelte';
import input from '$lib/actions/input'; import input from '$lib/actions/input';
import { BrowserOpenURL } from '$wails/runtime/runtime'; import { BrowserOpenURL } from '$wails/runtime/runtime';
import { onDestroy } from 'svelte';
export let host; export let host;
@ -15,9 +16,17 @@
let copySucceeded = false; let copySucceeded = false;
let autoReloadInterval = 0; let autoReloadInterval = 0;
let objectViewerData; let objectViewerData;
let interval;
$: filter && refresh(); $: filter && refresh();
$: busy = !logs && !error && 'Requesting logs…'; $: busy = !logs && !error && 'Requesting logs…';
$: if (autoReloadInterval) {
if (interval) {
clearInterval(interval);
}
interval = setInterval(refresh, autoReloadInterval * 1000);
}
async function refresh() { async function refresh() {
let _logs = []; let _logs = [];
({ logs: _logs, total, error } = await host.getLogs(filter)); ({ logs: _logs, total, error } = await host.getLogs(filter));
@ -44,6 +53,12 @@
copySucceeded = true; copySucceeded = true;
setTimeout(() => copySucceeded = false, 1500); setTimeout(() => copySucceeded = false, 1500);
} }
onDestroy(() => {
if (interval) {
clearInterval(interval);
}
});
</script> </script>
<div class="stats"> <div class="stats">