Skip to content

Commit

Permalink
fix: update cron text reactively
Browse files Browse the repository at this point in the history
  • Loading branch information
seriousm4x committed Sep 3, 2024
1 parent 4a9d1c0 commit e3259b1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions frontend/src/lib/components/DeviceCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
});
}
function getNextCronRelativeTime(expression: string) {
function getNextCronRelativeTime(expression: string, now: number) {
const cron = cronParser.parseExpression(expression);
return formatRelative(cron.next().toISOString(), now, {
locale: dateFnsLocale
Expand All @@ -156,14 +156,17 @@
{#if device.wake_cron_enabled}
<div class="tooltip" data-tip={$LL.device.card_tooltip_wake_cron()}>
<span class="badge badge-success gap-1 p-3"
><Fa icon={faCircleArrowUp} />{getNextCronRelativeTime(device.wake_cron)}</span
><Fa icon={faCircleArrowUp} />{getNextCronRelativeTime(device.wake_cron, now)}</span
>
</div>
{/if}
{#if device.shutdown_cron_enabled}
<div class="tooltip" data-tip={$LL.device.card_tooltip_shutdown_cron()}>
<span class="badge badge-error gap-1 p-3"
><Fa icon={faCircleArrowDown} />{getNextCronRelativeTime(device.shutdown_cron)}</span
><Fa icon={faCircleArrowDown} />{getNextCronRelativeTime(
device.shutdown_cron,
now
)}</span
>
</div>
{/if}
Expand Down

0 comments on commit e3259b1

Please sign in to comment.