diff --git a/internal/pomodoro/pomodoro.go b/internal/pomodoro/pomodoro.go index be39e6e..c24d4a5 100644 --- a/internal/pomodoro/pomodoro.go +++ b/internal/pomodoro/pomodoro.go @@ -2,6 +2,7 @@ package pomodoro import ( "git.smsvc.net/pomodoro/GoTomato/internal/shared" + "git.smsvc.net/pomodoro/GoTomato/pkg/models" "sync" "time" ) @@ -99,3 +100,10 @@ func IsPomodoroPaused() bool { defer mu.Unlock() // Ensures that the mutex is unlocked after the function is done return shared.Message.Paused } + +func UpdateSettings(settings models.PomodoroConfig) { + if settings != (models.PomodoroConfig{}) { + shared.Message.Settings = settings + shared.Message.TimeLeft = settings.Work + } +} diff --git a/internal/websocket/client_commands.go b/internal/websocket/client_commands.go index cafcd67..c1f323f 100644 --- a/internal/websocket/client_commands.go +++ b/internal/websocket/client_commands.go @@ -49,11 +49,7 @@ func handleClientCommands(ws *websocket.Conn) { } case "updateSettings": if !pomodoro.IsPomodoroOngoing() { - if clientCommand.Settings != (models.PomodoroConfig{}) { - shared.Message.Settings = clientCommand.Settings - shared.Message.TimeLeft = clientCommand.Settings.Work - } - + pomodoro.UpdateSettings(clientCommand.Settings) } } }