Skip to content

Commit

Permalink
feat: allow add time to aux timer
Browse files Browse the repository at this point in the history
  • Loading branch information
cpvalente committed Dec 2, 2024
1 parent 7dec32a commit 1e8706a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apps/server/src/api-integration/integration.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ const actionHandlers: Record<string, ActionHandler> = {
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);
Expand Down
5 changes: 5 additions & 0 deletions apps/server/src/services/aux-timer-service/AuxTimerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 1e8706a

Please sign in to comment.