From dcb1779e0a08e2ca4bd6a6ae912456e2a41c3418 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Thu, 15 Dec 2022 16:29:48 +0100 Subject: [PATCH] Ensure there is always items --- ui/src/lib/alarmrepeated.js | 6 +++++- ui/src/lib/alarmsingle.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ui/src/lib/alarmrepeated.js b/ui/src/lib/alarmrepeated.js index baef914..27002fe 100644 --- a/ui/src/lib/alarmrepeated.js +++ b/ui/src/lib/alarmrepeated.js @@ -9,11 +9,15 @@ export class AlarmRepeated { this.id = id; this.weekday = weekday; this.time = time; - this.routines = routines; + this.routines = routines == null ? [] : routines; this.ignore_exceptions = ignore_exceptions; this.comment = comment; this.excepts = excepts; this.next_time = next_time; + + if (this.routines.length < 1) { + this.routines.push(""); + } } async delete() { diff --git a/ui/src/lib/alarmsingle.js b/ui/src/lib/alarmsingle.js index f8e5927..8a171b3 100644 --- a/ui/src/lib/alarmsingle.js +++ b/ui/src/lib/alarmsingle.js @@ -8,8 +8,12 @@ export class AlarmSingle { update({ id, time, routines, comment }) { this.id = id; this.time = new Date(time); - this.routines = routines; + this.routines = routines == null ? [] : routines; this.comment = comment; + + if (this.routines.length < 1) { + this.routines.push(""); + } } async delete() {