diff --git a/frontend/src/lib/components/DeviceCard.svelte b/frontend/src/lib/components/DeviceCard.svelte index a4c4b534..cc9fd27a 100644 --- a/frontend/src/lib/components/DeviceCard.svelte +++ b/frontend/src/lib/components/DeviceCard.svelte @@ -19,11 +19,9 @@ import { scale } from 'svelte/transition'; import DeviceCardNic from './DeviceCardNic.svelte'; - export let device: Device; - + let { device = $bindable() }: { device: Device } = $props(); let modalReboot: HTMLDialogElement; - - $: moreButtons = [ + let moreButtons = $derived([ { text: m.device_card_btn_more_sleep(), icon: faBed, @@ -48,18 +46,17 @@ onClick: () => goto(`/device/${device.id}`), requires: $pocketbase.authStore.isSuperuser || $permission.update?.includes(device.id) } - ]; + ]); // update device status change - let now = Date.now(); + let now = $state(Date.now()); let interval: number; - $: { + $effect(() => { clearInterval(interval); interval = setInterval(() => { - // eslint-disable-next-line svelte/infinite-reactive-loop now = Date.now(); }, 1000); - } + }); function sleep() { fetch(`${backendUrl}api/upsnap/sleep/${device.id}`, { @@ -146,7 +143,7 @@ {#each moreButtons as btn, i (i)} {#if btn.requires}