From 63e71dc96b5a6ff3f00dd7d26c4aaca7401a62a5 Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 1 Aug 2023 11:20:51 -0600 Subject: [PATCH] Etemplate: If countdown time changes, avoid multiple updates / alarms --- api/js/etemplate/et2_widget_countdown.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/js/etemplate/et2_widget_countdown.ts b/api/js/etemplate/et2_widget_countdown.ts index c7458fed3f..0e8cc513fd 100644 --- a/api/js/etemplate/et2_widget_countdown.ts +++ b/api/js/etemplate/et2_widget_countdown.ts @@ -101,6 +101,12 @@ export class et2_countdown extends et2_valueWidget { if (isNaN(_time)) return; super.set_value(_time); + + if(this.timer) + { + clearInterval(this.timer); + } + this.time = new Date(); this.time.setSeconds(this.time.getSeconds() + parseInt(_time));