From 47d6b805114aab7e8b43ce2378b347a143301f47 Mon Sep 17 00:00:00 2001 From: Christian Weimann Date: Fri, 10 Jan 2025 06:08:04 +0100 Subject: [PATCH] refactor(TimerMgr): streamline timer identification and logging --- utils/TimerMgr.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/utils/TimerMgr.js b/utils/TimerMgr.js index a63abe2..b868f3d 100644 --- a/utils/TimerMgr.js +++ b/utils/TimerMgr.js @@ -18,23 +18,23 @@ class TimerMgr { this.#timers[id] = actions.ScriptExecution.createTimer(id, timeout, func); } - cancel(identifier) { - // Return if no timer with the respactive identifier is available - if (!this.#timers.hasOwnProperty(identifier)) { - log.debug(`No timer with identifier ${identifier} available to cancel`); + cancel(id) { + // Return if no timer with the respactive id is available + if (!this.hasTimer(id)) { + log.warn(`No timer with id ${id} available to cancel`); return false; } // Check if timer is active - if (!this.#timers[identifier].isActive()) { - log.debug(`Timer with identifier ${identifier} not running. Cancel anyway`); + if (!this.#timers[id].isActive()) { + log.debug(`Timer with id ${id} not running. Cancel anyway`); } else { - log.debug(`Cancel timer with identifier ${identifier}`); + log.debug(`Cancel timer with identifier ${id}`); } // Cancel timer - this.#timers[identifier].cancel(); - delete this.#timers[identifier]; + this.#timers[id].cancel(); + delete this.#timers[id]; } hasTimer(id) {