From 1e8706aa73c51b3a06952cd55e3f865ac61f3607 Mon Sep 17 00:00:00 2001 From: Carlos Valente Date: Sun, 1 Dec 2024 22:20:40 +0100 Subject: [PATCH] feat: allow add time to aux timer --- apps/server/src/api-integration/integration.controller.ts | 5 +++++ .../server/src/services/aux-timer-service/AuxTimerService.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/apps/server/src/api-integration/integration.controller.ts b/apps/server/src/api-integration/integration.controller.ts index a9e83e035..ded76835e 100644 --- a/apps/server/src/api-integration/integration.controller.ts +++ b/apps/server/src/api-integration/integration.controller.ts @@ -241,6 +241,11 @@ const actionHandlers: Record = { const timeInMs = numberOrError(command.duration) * 1000; reply.payload = auxTimerService.setTime(timeInMs); } + if ('addtime' in command) { + // convert addTime in seconds to ms + const timeInMs = numberOrError(command.addtime) * 1000; + reply.payload = auxTimerService.addTime(timeInMs); + } if ('direction' in command) { if (command.direction === SimpleDirection.CountUp || command.direction === SimpleDirection.CountDown) { reply.payload = auxTimerService.setDirection(command.direction); diff --git a/apps/server/src/services/aux-timer-service/AuxTimerService.ts b/apps/server/src/services/aux-timer-service/AuxTimerService.ts index 48d9157f2..396d4cb3b 100644 --- a/apps/server/src/services/aux-timer-service/AuxTimerService.ts +++ b/apps/server/src/services/aux-timer-service/AuxTimerService.ts @@ -57,6 +57,11 @@ export class AuxTimerService { return this.timer.setTime(duration); } + @broadcastReturn + addTime(millis: number) { + return this.timer.setTime(this.timer.state.current + millis); + } + @broadcastReturn private update() { return this.timer.update(this.getTime());