Compare commits

...

2 Commits

Author SHA1 Message Date
Christian Weimann
e299b96d15 fix(timer): handle missing timer in isActive method 2025-01-10 06:03:23 +01:00
Christian Weimann
7852cda9e6 fix(timers): prevent duplicate timer creation 2025-01-10 06:00:17 +01:00

View File

@@ -10,6 +10,10 @@ class TimerMgr {
}
create(id, timeout, func) {
if (this.hasTimer(id)) {
log.error(`Timer with id ${id} already exists`);
return;
}
log.debug("Create timer with id " + id);
this.#timers[id] = actions.ScriptExecution.createTimer(id, timeout, func);
}
@@ -37,8 +41,12 @@ class TimerMgr {
return this.#timers.hasOwnProperty(id);
}
isActive(identifier) {
return this.#timers[identifier].isActive();
isActive(id) {
if (!this.hasTimer(id)) {
log.warn(`No timer with id ${id} found`);
return false;
}
return this.#timers[id].isActive();
}
cancelAll() {