From 24fdfc68c39d34a950202913a4cd12cd1d5ffb81 Mon Sep 17 00:00:00 2001 From: Mik Mueller <83001409+MikMuellerDev@users.noreply.github.com> Date: Sun, 15 May 2022 21:53:49 +0200 Subject: [PATCH] Update Homescript data on automation edit --- web/src/pages/automations/Automation.svelte | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/web/src/pages/automations/Automation.svelte b/web/src/pages/automations/Automation.svelte index da2826a3..57df3fa5 100644 --- a/web/src/pages/automations/Automation.svelte +++ b/web/src/pages/automations/Automation.svelte @@ -32,7 +32,7 @@ }, } - interface timeDataType { + interface timeDataType { hours: number minutes: number days: number[] @@ -47,7 +47,7 @@ async function modifyAutomation(id: number, payload: addAutomation) { $loading = true try { - payload["id"] = id + payload['id'] = id const res = await ( await fetch('/api/automation/modify', { method: 'PUT', @@ -56,7 +56,16 @@ }) ).json() if (!res.success) throw Error(res.error) - data.cronExpression = generateCronExpression(payload.hour, payload.minute, payload.days) + data.cronExpression = generateCronExpression( + payload.hour, + payload.minute, + payload.days + ) + const homescriptDataTemp = $homescripts.find( + (s) => s.data.id === data.homescriptId + ) + if (homescriptDataTemp !== undefined) + homescriptData = homescriptDataTemp } catch (err) { $createSnackbar(`Could not modify automation: ${err}`) } @@ -100,7 +109,7 @@