From 5bf9753dce0fdac6ba6e442f53023b404cada445 Mon Sep 17 00:00:00 2001 From: Sebastian Mark Date: Tue, 22 Oct 2024 10:39:53 +0200 Subject: [PATCH] fix: `ResetPomodoro()` resets to current settings not server defaults - reset shared.Message fields to current values in `ResetPomodoro()` function - remove `ResetToDefault()` --- internal/pomodoro/pomodoro.go | 8 ++++---- internal/shared/state.go | 18 +++++++----------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/internal/pomodoro/pomodoro.go b/internal/pomodoro/pomodoro.go index 65ef873..9d9defc 100644 --- a/internal/pomodoro/pomodoro.go +++ b/internal/pomodoro/pomodoro.go @@ -2,7 +2,6 @@ package pomodoro import ( "git.smsvc.net/pomodoro/GoTomato/internal/shared" - // "git.smsvc.net/pomodoro/GoTomato/pkg/models" "sync" ) @@ -47,11 +46,12 @@ func RunPomodoro() { mu.Unlock() } -// ResetPomodoro resets the running Pomodoro timer. +// Stops and resets the running Pomodoro func ResetPomodoro() { - // Send a reset signal to stop any running timers + shared.Message.Mode = "Idle" + shared.Message.Session = 0 + shared.Message.TimeLeft = shared.Message.PomodoroSettings.Work pomodoroResetChannel <- true - shared.Message = shared.ResetToDefault() } func PausePomodoro() { diff --git a/internal/shared/state.go b/internal/shared/state.go index 0c1beb6..04c6949 100644 --- a/internal/shared/state.go +++ b/internal/shared/state.go @@ -4,17 +4,13 @@ import ( "git.smsvc.net/pomodoro/GoTomato/pkg/models" ) -var Message = ResetToDefault() - -func ResetToDefault() models.ServerMessage { - return models.ServerMessage{ - Mode: "Idle", - PomodoroSettings: DefaultPomodoroConfig, - Session: 0, - TimeLeft: DefaultPomodoroConfig.Work, - Ongoing: false, - Paused: false, - } +var Message = models.ServerMessage{ + Mode: "Idle", + PomodoroSettings: DefaultPomodoroConfig, + Session: 0, + TimeLeft: DefaultPomodoroConfig.Work, + Ongoing: false, + Paused: false, } var PomodoroPassword string